From 898e42e0b763f22ff0acb3c8f3cef5009d5a8300 Mon Sep 17 00:00:00 2001 From: iosullivan Date: Sat, 18 Jul 2026 15:19:06 +0800 Subject: [PATCH] Fix crontab permissions --- Dockerfile | 2 +- archive.py | 4 ++++ cronjob | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c26aa0..245e521 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN chmod 0644 /etc/cron.d/cronjob RUN crontab /etc/cron.d/cronjob # Create the log file to be able to run tail -RUN touch /var/log/cron.log +RUN touch /var/log/cron_python.log # Run the command on container startup CMD ["cron","-f" ] \ No newline at end of file diff --git a/archive.py b/archive.py index c1dc8bb..fa15f3c 100644 --- a/archive.py +++ b/archive.py @@ -3,6 +3,10 @@ import datetime import os import json +# Move to script directory in case it was run elsewhere. +scriptdir = os.path.dirname(os.path.abspath(__file__)) +os.chdir(scriptdir) + # Import API key from .env file api_key=os.environ['API_KEY'] diff --git a/cronjob b/cronjob index 5ca28b8..af62af9 100644 --- a/cronjob +++ b/cronjob @@ -1 +1 @@ -5 * * * * python3 /usr/cta-archive/archive.py > /proc/1/fd/1 2>/proc/1/fd/2 +5 * * * * root python3 /usr/cta-archive/archive.py