Skip to content
Snippets Groups Projects
Commit 0f605d91 authored by Joost Hemmen's avatar Joost Hemmen :basketball: Committed by Bert Palm
Browse files

update crontab automatically on changes to crontab.txt

parent fc3fd822
No related branches found
No related tags found
1 merge request!141Resolve "create sftp sync job"
Pipeline #374990 passed
......@@ -2,13 +2,26 @@
set -e
if [ "$SETUP_SERVICE" == "true" ]; then
echo "SETUP_SERVICE has value '$SETUP_SERVICE' - starting cron setup."
# Function to update crontab from crontab.txt
update_crontab() {
# prepend environment variables to /tmp/new_crontab.txt
# to be able topass them to cron jobs
(printenv; cat /tmp/crontab.txt) > /tmp/new_crontab.txt
# use /tmp/new_crontab.txt as crontab
crontab /tmp/new_crontab.txt
}
if [ "$SETUP_SERVICE" == "true" ]; then
echo "SETUP_SERVICE has value '$SETUP_SERVICE' - starting cron setup."
# Monitor crontab.txt for changes and update crontab if they occurr
# run loop in background to start cron service
while true; do
update_crontab
inotifywait -e modify /tmp/crontab.txt
done &
sleep 1
cron -f || exit 1
echo "cron setup complete."
else
echo "SETUP_SERVICE has value '$SETUP_SERVICE' - skipping cron setup."
echo "To start cron setup, set SETUP_SERVICE to 'true' in .env file."
fi
\ No newline at end of file
fi
psycopg2-binary~=2.9.2
\ No newline at end of file
psycopg2-binary~=2.9.2
python-crontab~=3.0.0
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment