0

I am running the monitoring scripts in the background. They are supposed to all day (24x7).

In the script, based on the monitor output I have a function to start a process using nohup, redirecting the output to the log file /home/nohub_logs/logfile.txt.

The script works fine for few hours but after these few hours the log file is still zero bytes length. Sometimes if I kill the monitoring script and restart the script I get some output.

nohup startprocessscript.sh >> /home/nohuplog &

Logs are getting generated after some time. For example, if the script is running for the first 24 hours, then after 24 hours the logs are not getting created. If we restart the script the logs are created.

I am not sure why sometime the nohup log files are not getting any generated data. Can anyone help me, please.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • It seems that some logs are created and updated fine, while some are not. Can you elaborate on that? – Zip Oct 30 '17 at 13:47
  • nohup startprocessscript.sh >> /home/nohuplog & this is the command I am using logs are getting generated after some times say script is working for first 24 hours .. after 24 hours the logs are not getting created. if we restart the script the logs are created. – Hari Kris Oct 30 '17 at 14:01
  • You wrote "filled with 0 bytes", but you really mean that the output files stays empty (at size zero)? – dhag Oct 30 '17 at 15:45

1 Answers1

2

A common reason for this issue is output buffering.

Your script output might be flushed to the log file only after enough data has been written.

Possible workarounds are stdbuf and unbuffer see Turn off buffering in pipe

jlliagre
  • 61,204