Issue
I'm trying to run a ruby script with nohup
:
nohup ruby script.rb &
This takes hours to run, but logs its progress via puts
.
Usually, I can look at nohup.out to view the recent output of anything I run with nohup. However, my ruby script doesn't seem to output anything until it finishes, or is killed.
What am I doing wrong?
Solution
I'm not familiar with running commands through nohup
, but approaching this from a "I'm outputting content to a file and it's only being written after the script exits" type of problem, those are caused by the output being buffered.
So it's very likely that being run through nohup
(and thus redirecting the puts
output to nohup.out) you lost synchronization. You might need to flush
occasionally or enable sync
. Since puts
is "equivalent to $stdout.puts
":
$stdout.flush # run this, occasionally
# or just
$stdout.sync = true
Answered By - Simple Lime Answer Checked By - Candace Johnson (WPSolving Volunteer)