Reputation: 983
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.
Upvotes: 1
Views: 58
Reputation: 386
You're probably looking for nohup.
nohup python script.py > output.txt 2^C1 &
It allows you to logout with the script still running.
Upvotes: 3
Reputation: 3741
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
Upvotes: 2