DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Maintenance Of Rails Programs
This is a maintenance script, yanked from Lucas Carlson's blog. Put this in your rails app to have a quick and dirty server maintenance cleanup app:
original at: http://tech.rufy.com/entry/15
pid_file = '/tmp/running.pid'
begin
File.stat pid_file
rescue
f = File.new pid_file, 'w'
f < < fork {
loop {
# do lots of maintenance
sleep 15*60
}
}
f.close
end
Finally, if your maintenance code needs to be changed, a couple simple commands can restart the new maintenance code:
kill `cat /tmp/running.pid` rm /tmp/running.pid





