update cron job

This commit is contained in:
MuslemRahimi 2024-10-04 14:30:24 +02:00
parent f885de8b23
commit 1358c72cd9
2 changed files with 8 additions and 14 deletions

View File

@ -236,16 +236,6 @@ def run_ta_rating():
] ]
run_command(command) run_command(command)
def run_stockdeck():
week = datetime.today().weekday()
if week <= 5:
run_command(["python3", "cron_stockdeck.py"])
command = [
"sudo", "rsync", "-avz", "-e", "ssh",
"/root/backend/app/json/stockdeck",
f"root@{useast_ip_address}:/root/backend/app/json"
]
run_command(command)
def run_similar_stocks(): def run_similar_stocks():
week = datetime.today().weekday() week = datetime.today().weekday()
@ -637,7 +627,6 @@ schedule.every().day.at("12:00").do(run_threaded, run_market_cap).tag('market_ca
#schedule.every().day.at("05:00").do(run_threaded, run_implied_volatility).tag('implied_volatility_job') #schedule.every().day.at("05:00").do(run_threaded, run_implied_volatility).tag('implied_volatility_job')
schedule.every().day.at("13:30").do(run_threaded, run_stockdeck).tag('stockdeck_job')
schedule.every().day.at("13:40").do(run_threaded, run_analyst_estimate).tag('analyst_estimate_job') schedule.every().day.at("13:40").do(run_threaded, run_analyst_estimate).tag('analyst_estimate_job')
schedule.every().day.at("13:45").do(run_threaded, run_similar_stocks).tag('similar_stocks_job') schedule.every().day.at("13:45").do(run_threaded, run_similar_stocks).tag('similar_stocks_job')
schedule.every().day.at("14:00").do(run_threaded, run_cron_var).tag('var_job') schedule.every().day.at("14:00").do(run_threaded, run_cron_var).tag('var_job')

View File

@ -24,7 +24,7 @@ subprocess.run(["timedatectl", "set-timezone", "Europe/Berlin"])
def run_pocketbase(): def run_pocketbase():
# Run the asynchronous function inside an asyncio loop # Run the asynchronous function inside an asyncio loop
run_command(["python3", "cron_pocketbase.py"]) subprocess(["python3", "cron_pocketbase.py"])
def run_restart_cache(): def run_restart_cache():
#update db daily #update db daily
@ -33,6 +33,10 @@ def run_restart_cache():
subprocess.run(["pm2", "restart","fastapi"]) subprocess.run(["pm2", "restart","fastapi"])
subprocess.run(["pm2", "restart","fastify"]) subprocess.run(["pm2", "restart","fastify"])
def run_stockdeck():
week = datetime.today().weekday()
if week <= 5:
subprocess(["python3", "cron_stockdeck.py"])
def run_json_job(): def run_json_job():
# Run the asynchronous function inside an asyncio loop # Run the asynchronous function inside an asyncio loop
@ -43,7 +47,7 @@ def run_json_job():
def run_cron_price_alert(): def run_cron_price_alert():
week = datetime.today().weekday() week = datetime.today().weekday()
if week <= 4: if week <= 4:
run_command(["python3", "cron_price_alert.py"]) subprocess(["python3", "cron_price_alert.py"])
# Create functions to run each schedule in a separate thread # Create functions to run each schedule in a separate thread
def run_threaded(job_func): def run_threaded(job_func):
@ -52,6 +56,7 @@ def run_threaded(job_func):
schedule.every().day.at("06:30").do(run_threaded, run_pocketbase).tag('pocketbase_job') schedule.every().day.at("06:30").do(run_threaded, run_pocketbase).tag('pocketbase_job')
schedule.every().day.at("13:30").do(run_threaded, run_stockdeck).tag('stockdeck_job')
schedule.every().day.at("15:45").do(run_threaded, run_restart_cache) schedule.every().day.at("15:45").do(run_threaded, run_restart_cache)
schedule.every(2).hours.do(run_threaded, run_json_job).tag('json_job') schedule.every(2).hours.do(run_threaded, run_json_job).tag('json_job')
schedule.every(1).minutes.do(run_threaded, run_cron_price_alert).tag('price_alert_job') schedule.every(1).minutes.do(run_threaded, run_cron_price_alert).tag('price_alert_job')