0

I wrote a simple master-slave failover setup for my two servers using c, running redhat6 which using udp heartbeats to monitor one another. In my app I'm printing out some information like, heartbeat received, server is healthy and some more stuff. I want it to run in background and appending those printfs to nohup.out. So I issued below,

nohup ./appname &

nohup: ignoring input and appending output to nohup.out

App is running in background, but output is not appended to nohup.out. I thought it was buffered, so I gave sometime and killed it, but nohup.out is still empty,

Any thoughts in this?

ivcode
  • 1,062
  • 1
  • 9
  • 13
  • This http://stackoverflow.com/questions/12919980/nohup-is-not-writing-log-to-output-file describes a similar issue in Python. Have you tried explicitly flushing stdout? – greg May 25 '15 at 04:45
  • Thank you @greg. Seems like I was not giving enough time, nohup.out is buffered. Will try flushing std out more often – ivcode May 25 '15 at 04:54

1 Answers1

0

As @greg pointed out, nohup.out was buffered. Setting buffer size of stdout to null solved it.

setbuf(stdout, NULL);

ivcode
  • 1,062
  • 1
  • 9
  • 13