Reputation: 8954
I have a two scripts in the Rails environment which have to run 24/7. I'm working on a remote server, so I need to start the scripts using ssh
, which means I need to keep the ssh windows open all the time.
I'm searching for a simple way to run these scripts in the background so they aren't canceled as soon as I close the ssh connection.
I don't want to use screen
. I think there must be simpler way to handle this. Isn't there?
Upvotes: 10
Views: 10220
Reputation: 21690
You can disown a script:
ruby script.rb &!
STDOUT/STDERR are still attached to the current shell, but the ruby
process isn't a child of the shell anymore, so it won't get killed if you close the terminal.
Upvotes: 4
Reputation: 6710
Check Daemons. It's a toolkit for converting a script to a controllable daemon.
Upvotes: 2
Reputation: 606
I think the most basic solution would be nohup
:
nohup myscript &> /dev/null &
Upvotes: 23
Reputation: 83680
You can use
For daemonizing
Or some ruby stuff: https://www.ruby-toolbox.com/#Background_Processing for background processing
Upvotes: 1