Search code examples
pythonseleniumserverubuntu-16.04nohup

How to run the Python program in the background in Ubuntu server


I have a python script. Script have selenium with Chrome and go to a website, take data and put in CSV file.
This is a very long work.
I put the script on the server. And run. All work. But I need script work in the background.

chmod +x createdb.py
nohup python ./createdb.py &

And I see

(env)$ nohup ./createdb.py &
[1] 32257
(env)$ nohup: ignoring input and appending output to 'nohup.out'

Press Enter.

(env)$ nohup ./createdb.py &
[1] 32257
(env)$ nohup: ignoring input and appending output to 'nohup.out'
[1]+  Exit 1                  nohup ./createdb.py

Then it runs and immediately writes errors to the file, that Chrome did not start or there was no click.
I want to remind you that if you start without nohup, then everything will work.
What am I doing wrong? How to run a script?
Thank you very much.


Solution

  • You can use the screen command, it works perfectly.

    Here is a very good link: https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/