running a script like a daemon

  • Thread starter ivan le magnifique
  • Start date
I

ivan le magnifique

Hi there.
I would like to know how to launch a script from the command line (like via
telnet) with the ability to exit the command line without stopping the
thead.
Afterwards I would like to be able to retrieve the id of the thread to kill
it.
I know this is not really Python related since I have had the problem with
Java already ( before my conversion to Python)... but, any idea would be
appreciated.

Thanks :)
 
A

Alex Martelli

ivan said:
I would like to know how to launch a script from the command line (like
via telnet) with the ability to exit the command line without stopping the
thead.
Afterwards I would like to be able to retrieve the id of the thread to
kill it.
I know this is not really Python related since I have had the problem with
Java already ( before my conversion to Python)... but, any idea would be
appreciated.

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012

To write the daemon's pid to a suitable file (you wrote thread, but that
makes no sense -- I assume you mean process...?!), see os.getpid.


Alex
 
K

Kathy Poniatowski

In most flavors of Unix, you can append the '&' character to the command,
which causes it to execute as a background process, and prepend 'nohup' to
it, which I think makes it continue even if you log off. I'm not a Unix
expert, so my explanation may be flawed, but this is what works for me:
nohup command &

Jp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top