-1

I created a Daemon process with these liblinktosite I connect trough ssh and start the process with python myDaemon.py start.

I use a loop within the daemon method to do my tasks. But as soon as I logout the daemon stops(dies).

Does this happen because I save the PID file on my user and not in the root folder?

Anyone a idea. I can deliver code but now on Thread creation.(+3h)

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
Offset
  • 609
  • 1
  • 5
  • 22
  • 1
    Did you pass a `detach` option? Does it make a difference if you do `nohup python myDaemon.py start&` (it shouldn't, but if it does then the problem is there). – RemcoGerlich Oct 10 '16 at 11:26
  • Are you certain that the host does in principle allow background processes to run after logout? Some systems are configured to kill all processes once the interactive session ends. (Try running, e.g., `nohup cat &`, logout, log back in and check whether `cat` still occurs in `ps`.) – Phillip Oct 10 '16 at 11:31
  • neither with nohop or without the process is not showing with ps. /e what is the & for? – Offset Oct 10 '16 at 11:38
  • @Offset Does a `screen` or `tmux` session survive a logout? – Phillip Oct 12 '16 at 09:11
  • Sorry but I never heard of those to options. Rather used nor tested them. – Offset Oct 12 '16 at 10:07

1 Answers1

-1

Use the shebang line in your python script. Make it executable using the command. chmod +x test.py Use no hangup to run a program in background even if you close your terminal.

nohup /path/to/test.py &

Do not forget to use & to put it in background.

To see the process again, use in terminal,

ps ax | grep test.py

Answer

Another way would be actually make it an upstart script

Community
  • 1
  • 1
xssChauhan
  • 2,728
  • 2
  • 25
  • 36