简体   繁体   中英

Accidentally failing command in linux

I have server and connect to it via ssh, I would like to run command and then disconnect from server thinking, that process is running and will be finished in few hours. So I came up with

python script.py > output.txt 2^C1 & 

it works! ... well sometimes .. and sometimes (exactly the same python script) it fails without leaving any error msg in output.txt. Does anyone know why? And what should I be running to prevent failing?

I doubt that it has something to do with python script.

You're probably looking for nohup.

nohup python script.py > output.txt 2^C1 &

It allows you to logout with the script still running.

It won't leave any error message in output.txt, Try this

python script.py 1> output.txt 2>error.txt 2^C1 &

If your script fails it should log reason in error.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM