Never been to DZone Snippets before?

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

About this user

Rick Olson http://techno-weenie.net

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

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

   1  
   2  pid_file = '/tmp/running.pid'
   3  begin
   4    File.stat pid_file
   5  rescue
   6    f = File.new pid_file, 'w'
   7    f < < fork {
   8      loop {
   9        # do lots of maintenance
  10        sleep 15*60
  11      }
  12    }
  13    f.close
  14  end


Finally, if your maintenance code needs to be changed, a couple simple commands can restart the new maintenance code:

   1  
   2  kill `cat /tmp/running.pid`
   3  rm /tmp/running.pid
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS