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