Run ruby โ€‹โ€‹script in background without using screen

I have two scripts in a Rails environment that should run 24/7. I work on a remote server, so I need to run scripts using ssh , which means that I need to constantly open ssh windows.

I am looking for an easy way to run these scripts in the background so that they are not canceled as soon as I close the ssh connection.

I do not want to use screen . I think there should be an easier way to handle this. Does not exist?

+7
source share
4 answers

I think the most basic solution would be nohup :

 nohup myscript &> /dev/null & 
+20
source

You can opt out of the script:

  ruby script.rb &! 

STDOUT / STDERR are still tied to the current shell, but the ruby process is no longer a child of the shell, so it will not be killed if you close the terminal.

+4
source

Check Daemons . This is a toolkit for converting a script into a managed daemon.

+2
source

you can use

For demonization

Or some ruby โ€‹โ€‹material: https://www.ruby-toolbox.com/#Background_Processing for background processing

+1
source

All Articles