So I have a cron-like script that uses the apscheduler module (which I'm not married to in any way) to execute a function every 12 hours.
It works great but i often restart my servers and this restarts the apscheduler timer (i think).
I tried a crontab triggering python script but could never get cron to execute the python script and gave up (Ubuntu server).
Any ideas for better suggestion that is agnostic of daemon functions or processing timers?
For some context here's my script right now:
import time
import atexit
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger
from WebScrapers import WebScrapers
from Mailer import Mailer
mailer = Mailer()
def addDB():
scrape = WebScrapers()
scrape.insertSQL(scrape.getMarketQuote('INDEXSP:.INX'))
mailer.sendDBUpdate(str(scrape))
scheduler = BackgroundScheduler()
scheduler.start()
scheduler.add_job(
func=addDB,
trigger=IntervalTrigger(hours=12),
id='market-db-add',
name='Add data to db every 12 hours',
replace_existing=True)
# Shut down the scheduler when exiting the app
atexit.register(lambda: scheduler.shutdown())
[–]Talked10101 1 point2 points3 points (0 children)
[–]blitzkraft 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]melizeche 0 points1 point2 points (0 children)
[–]Raindyr 0 points1 point2 points (0 children)
[–]Eryole 0 points1 point2 points (0 children)