blue-sky blue-sky - 11 months ago 220
Linux Question

Running tensorflow as daemon and piping all output to log file

To run tensorflow model as daemon I use :

nohup python --data_dir data &

This logs error messages to nohup.out but it does not capture Tensorflow stdout . This thread offers describes related :!topic/discuss/SO_JRts-VIs but does not provide solution.

I require to run as daemon as model takes quite some time to run. This is to prevent ssh disconnecting due to inactivity.

How to run Tensorflow as daemon process and pipe all output to file ?

Answer Source

Why not try

nohup python --data_dir data &> outputfile.txt

You can then suspend the file your self with kill -19 %1 to suspend the first job or whatever number its present as.

Other options:

  • tmux (as suggested in the comments)
  • screen (similar to tmux)
  • using mosh instead of ssh
  • save the outputs from within the file instead of printing to stdout