From 161502e214f6575f3d8d7968ecc644489673d16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l-Kristian=20Hamre?= Date: Tue, 22 Jul 2025 21:25:16 +0200 Subject: [PATCH] Added example cronjob. --- run_daily_job.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 run_daily_job.sh diff --git a/run_daily_job.sh b/run_daily_job.sh new file mode 100755 index 0000000..907a81f --- /dev/null +++ b/run_daily_job.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# CRITICAL: Navigate to the project directory using an absolute path. +cd /home/pkhamre/git/rstat + +# CRITICAL: Activate the virtual environment using an absolute path. +source /home/pkhamre/git/rstat/.venv/bin/activate + +echo "--- Starting RSTAT Daily Job on $(date +%F) ---" + +# 1. Scrape data from the last 24 hours. +echo "Step 1: Scraping new data..." +rstat -c 250 + +# 2. Start the dashboard in the background. +echo "Step 2: Starting dashboard in background..." +rstat-dashboard & +DASHBOARD_PID=$! +sleep 10 + +# 3. Export the overall summary image. +echo "Step 3: Exporting overall summary image..." +python export_image.py --overall + +# 4. Post the image to r/rstat. +echo "Step 4: Posting image to Reddit..." +python post_to_reddit.py --target-subreddit rstat + +# 5. Clean up by stopping the dashboard server. +echo "Step 5: Stopping dashboard server..." +kill $DASHBOARD_PID + +echo "--- RSTAT Daily Job Complete ---" \ No newline at end of file