Reputation: 153
I am currently creating a script that makes "statistics" and it has to run continually, and I would like to upload it on my webserver (it has cPanel) to run on it, and not on my computer. I want it to run in backround so I don't need to open any webpage or anyhting else. Is that possible?
Upvotes: 0
Views: 795
Reputation: 165
Supervisor is a good way to do this.
http://supervisord.org/ This allows you to run the script at boot just like a service. Also allows you to specify command line options and specify logging. Has options for auto restart.
Example config:
[program:test]
command=/usr/bin/python /home/ubuntu/test.py
directory=/home/ubuntu
autostart=true
autorestart=true
startretries=3
stderr_logfile=/home/ubuntu/test.err.log
stdout_logfile=/home/ubuntu/test.out.log
user=ubuntu
If you are looking to run it in the context of the web server, you might also looking to to Django, which is a Python web framework for web sites / applications. Then you could use Celery to schedule your Python functions. https://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
Upvotes: 1