I have a Ruby script that I need to have running all the time in my Linux box. I tried nohup ruby ruby.rb& but it seems it doesn’t work.
How can I have the script running in background?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Have a look at
screenwhich is a command-line utility. Start it withYou will get a new shell which is detached. Start your script there with
And watch it run. Then hit Ctrl–A Ctrl–D and you should be back at your original shell. You can leave the ssh session now, and the script will continue running. At a later time, login to your box and type
and you should be back to the detached shell.
If you use screen more than once, you will have to select the screen session by pid which is not so comfortable. To simplify, you can do
to start the session and
to resume it.