Run Ruby script in the background

后端 未结 2 1917
再見小時候
再見小時候 2021-01-31 23:30

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

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 23:56

    Depending on your needs:

    fork do
      Process.setsid
      sleep 5
      puts "In daemon"
    end
    puts "In control script"
    

    In real life you will have to reopen STDOUT/STDERR.

提交回复
热议问题