Python – Keeping a Python Script alive after leaving SSH Client

keepalivepythonscripting

I have a while loop in my Python Script and its independent script so I can't run it as a daemon.

Also I have tryed using nohup, but I'm having this error:

root@ubuntu:~/Desktop/starthere-group-ok# nohup python yApp.py &
[1] 3038
root@ubuntu:~/Desktop/starthere-group-ok# nohup: ignoring input and appending output to `nohup.out'

The nohup.out:

1) Deployment
2) Service Status
3) List Servers
4) Restart Service
5) Restart Server
6) Execute Commands on Servers
Seçiminizi yapın: Traceback (most recent call last):
  File "yApp.py", line 13, in <module>
    selection = raw_input("Seçiminizi yapın: ")
IOError: [Errno 9] Bad file descriptor

My script is kind of a job, I mean the Deployment part. It takes hours and hours sometimes and I can't leave the PuTTy open.

Seçiminizi yapın:
Means "Make your selection" in Turkish.

Maybe thats why I'm having this error? I'm using;

#!/usr/bin/env python
# -*- coding: utf-8 -*-

Metas at the beginning.

So, what should I do?

Thanks in advance.

Best Answer

You can use screen to keep your session alive

http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/

Or you could submit the job with "at"

http://linux.about.com/library/cmd/blcmdl1_at.htm

Related Topic