Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a python app in a remote server that i need to debug, when I run the app locally it prints some debug information (including python tracebacks) that i need to monitor.

Im trying to redirect all the output of the program to a file so I can monitor the remote output using tail -F, here I found the following command to redirect the outputs:

ssh root@myserver 'nohup python /root/python/run_dev_server.py &>> /var/log/myapp.log &'

This gets me almost exactly what i want, loggin information and python tracebacks, but i do not get any of the information displayed using print from python, which i need.

so I also tried this command:

ssh root@myserver 'nohup python /root/python/run_dev_server.py 2>&1 >> /var/log/myapp.log &'

this logs the output of the program from print and also the logging information, but all the tracebacks are sent to my local terminal where i excecuted the the script and my script gets stuck waiting for any exception to happen in the remote program.

Is there a way I can capture all the information produced by the app without stopping my script?

Thanks in advance for any suggestion.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You almost had it... However, all three pipes need to be re-directed to background a process via ssh. Std In, Std Out, Std Err. Thus:

nohup /root/python/run_dev_server.py &>/var/log/my.app.log </dev/null &

note: &> is the equivalent of redirecting std out and std error at the same time. In other words, it is the shortened version of ' >> /var/log/myapp.log 2>&1'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.