cron

python schedule jobs with different timezones

python schedule jobs with different timezones Question: I want to schedule a python function to run everyday at a certain time for a list of customers with different timezones. This is basically what I want to do: import schedule import time def job(text): print(“Hello ” + text) def add_job(user_tz, time, text): schedule.every().day.at(time).do(job(text)) # the above …

Total answers: 2

Running Python process with cronjob and checking it is still running every minute

Running Python process with cronjob and checking it is still running every minute Question: I have a Python script that I’d like to run from a cronjob and then check every minute to see if it is still running and if not then start it again. Cronjob is: /usr/bin/python2.7 /home/mydir/public_html/myotherdir/script.py there is some info on …

Total answers: 4

Crontab to launch python script on raspberry pi causes import error

Crontab to launch python script on raspberry pi causes import error Question: I am running Ubuntu Mate on my Raspberry PI. I wrote a web scraper in Python that I want to run once a day. I figured using sudo crontab -e would be a good way to do way. The problem that I’m having …

Total answers: 2

run a crontab job using an anaconda env

run a crontab job using an anaconda env Question: I want to have a cron job execute a python script using an already existing anaconda python environment called my_env. The only thing I can think to do is have the cron job run a script called my_script.bash which in turn activates the env and then …

Total answers: 8

Running cron python jobs within docker

Running cron python jobs within docker Question: I would like to run a python cron job inside of a docker container in detached mode. My set-up is below: My python script is test.py #!/usr/bin/env python import datetime print "Cron job has run at %s" %datetime.datetime.now() My cron file is my-crontab * * * * * …

Total answers: 9

How to run recurring task in the Python Flask framework?

How to run recurring task in the Python Flask framework? Question: I’m building a website which provides some information to the visitors. This information is aggregated in the background by polling a couple external APIs every 5 seconds. The way I have it working now is that I use APScheduler jobs. I initially preferred APScheduler …

Total answers: 1

Scheduling Python Script to run every hour accurately

Scheduling Python Script to run every hour accurately Question: Before I ask, Cron Jobs and Task Scheduler will be my last options, this script will be used across Windows and Linux and I’d prefer to have a coded out method of doing this than leaving this to the end user to complete. Is there a …

Total answers: 14

How to schedule a function to run every hour on Flask?

How to schedule a function to run every hour on Flask? Question: I have a Flask web hosting with no access to cron command. How can I execute some Python function every hour? Asked By: RomaValcer || Source Answers: You could make use of APScheduler in your Flask application and run your jobs via its …

Total answers: 10

Crontab not executing a Python script?

Crontab not executing a Python script? Question: My python script is not running under my crontab. I have placed this in the python script at the top: #!/usr/bin/python I have tried doing this: chmod a+x myscript.py Added to my crontab -e: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=”” * * * * * /home/me/project/myscript.py My /var/log/cron file says: Sep …

Total answers: 15

UnicodeEncodeError only when running as a cron job

UnicodeEncodeError only when running as a cron job Question: My program works right in the commandline, but when I run it as a cron job it crashes on the error: UnicodeEncodeError: ‘ascii’ codec can’t encode character u’xa7′ in position 13: ordinal not in range(128) It crashes on the statement print title Why this is happening …

Total answers: 2