Answer the question
In order to leave comments, you need to log in
Running python script in background?
Good evening! The essence of the problem.
There is a php script that communicates with another server via SSH using the phpseclib library.
There was a need to run a python script on a remote server from SSH.
I wrote this code, and I thought that everything would be ok:
$ssh->exec("nohup python ./script.py --params=1 >/dev/null 2>&1");
Answer the question
In order to leave comments, you need to log in
Usually they do this in the console:
ssh [email protected]_ip 'you command &'
And that's it & puts the command in the background, ssh returns control
Try using screen as a layer, or in your case, you need to run another script that will already run nohup python ./script.py --params=1 >/dev/null 2>&1
If in shell terms, then you need to do this:
ssh host "/path/to/python/script.py & bash" Translate
into python yourself)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question