Problem is when I run a script like:
python scripy.py
Then when I close the terminal the process is killed.
How to run script forever under Ubuntu 16.04.3 LTS?
I have created a service in /etc/init/publisher.conf
like this:
description "Publisher"
author "alissada@gmail.com.com"
start on runlevel [2345]
stop on runlevel [!2345]
env AN_ENVIRONMENTAL_VARIABLE=i-want-to-set
respawn
exec /var/www/__init__.py
When I tried to run this service:
service publisher start
I get an error:
Failed to start publisher.service: Unit publisher.service not found.
Why?
One way would be to use the 'screen' command to start detachable session (apt-get install screen if you don't have it). 'screen' creates what looks like a normal terminal, but you can detach from it (ctrl+a then d I think is the incantation). You can then logout, and whatever you started in the screen session will keep running.
Upon your later return, you can type screen --reattach (I think, you'll have to read the man page) to return to the session you abandoned earlier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.