If you are running Linux, you might consider using start-stop-daemon.
start-stop-daemon -S --pidfile /var/run/incoming_mail.pid -u rails_user -d /path/to/your/rails/app -b -a "rake incoming_mail"
To subsequently gracefully kill the process, you can use most of the arguments, but replace -S with -K.
As always, you can find more information about the start daemon by reading the man pages.
Maran source
share