Stored shit in your script's data segment.
$ gem install DATA.save
A program that records how many times it's been run:
require 'DATA.save'
run_count = DATA.load.to_i
run_count += 1
DATA.save run_count
puts "Run count: #{run_count}"
__END__
0
When we invoke it, it increments the counter,
which it stores in its DATA
segment.
# run it 3 times
$ ruby count_runs.rb
Run count: 1
$ ruby count_runs.rb
Run count: 2
$ ruby count_runs.rb
Run count: 3
# now check out the file
$ cat count_runs.rb
require 'DATA.save'
run_count = DATA.load.to_i
run_count += 1
DATA.save run_count
puts "Run count: #{run_count}"
__END__
3
Just do what the fuck you want to.