1

I am running Lubuntu 13.10 an have a python script that is run on boot through ~/.config/lxsession/Lubuntu/autostart. The script startes a web application and outputs various information to terminal output. I have made some changes now to the python script and wish to restart it, and keep it running in background.

Is it possible to connect/attach to the running python script through terminal so that I can see the scripts output? I tried reptyr but I get an error indicating it is a subprocess. Or, is this not possible and the only option to kill the process manually and than restart it through another terminal? Of course, on next boot the changes will take effect, but it is nice to know whether I can interact with running processes.

Thanks for your help.

4
  • Try killall {processname} to kill the process and then restart it via terminal. Does that work? If it does, let me know and I will post this as an answer. – Archisman Panigrahi Dec 25 '13 at 14:15
  • Thanks for your comment. I have updated my question to better reflect what I mean. I am more interested to be able to se the output from the running background script. – qtips Dec 26 '13 at 10:22
  • AFAIK if you you start an application in background using autostart in is not attached for input/output to a terminal. What do you mean by "and outputs various information to terminal output"? Usually output from processes running in background is redirected to a file. So if you restart the application it would continue outputting appending to the same file. – warvariuc Dec 26 '13 at 11:42
  • I consider this comment as an answer this question. Please do add this to your answer and i'll accept it. – qtips Dec 26 '13 at 20:49
0

"Connecting" to a script usually means your program is listening to a socket and you want to connect to that socket.

I guess you mean how to replace the script which is running in the background.

The simplest way is to kill the process and restart the new version to be run in the background from a terminal:

nohup python your_script.py &
2
  • You are correct. I have edited my question to better reflect what I mean. As the script outputs to terminal, I was woundering if there was a way to get see the terminal output from the script. Is this what you mean with connecting to socket? – qtips Dec 26 '13 at 10:19
  • No, connecting to a socket is something totally different. – warvariuc Dec 26 '13 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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