I am running a python script of web2py and want to log its output. I am using following command nohup python /var/www/web2py/web2py.py -S cloud -M -N -R applications/cloud/private/process.py >>/var/log/web2pyserver.log 2>&1 &

The process is running but it is not logging into the file. I have tried without nohup also but it is still same. The default logging of nohup in nohup.out is also not working. Any suggestion what might be going wrong?

有帮助吗?

解决方案

Nothing to worry. Actually the python process along with nohup was logging the file in batch mode and i could see the output only after quite some time and not instantaneously.

其他提示

nohup will try to create the file in the local directory. Can you create a file in the folder you are running it from ?

If you've got commas in your print statements there's a good chance it's due to buffering. You can put a sys command (forget which) in your code or when you run the nohup, just add the option -u and you'll disable std(in|out|err) buffering

Don't worry about this, it is because of the buffering mechanism, run your Python script with the -u flag will solve the problem:

nohup python -u code.py > code.log &

or just

nohup python -u code.py &
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top