Daemonize a Ruby process
#!/usr/bin/ruby pid = fork do loop do // Some code sleep 1.minute end end Process.detach(pid)
In my case, I just needed some code to run each minute, but it is part of a Rails app, so I didn't just want to start it with cron every minute (Rails loading is expensive). Neat eh?