Skip to content

Commit

Permalink
Docker
Browse files Browse the repository at this point in the history
Reset crontab file before adding the cron expression to prevent multiplying the same entry on every container restart
Fixes #1
  • Loading branch information
Salvoxia committed Feb 26, 2024
1 parent 412347f commit 6e03f20
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docker/setup_cron.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/usr/bin/env sh

if [ ! -z "$CRON_EXPRESSION" ]; then
(crontab -l 2>/dev/null; echo "$CRON_EXPRESSION /script/immich_auto_album.sh > /proc/1/fd/1 2>/proc/1/fd/2") | crontab -
CRONTAB="$CRON_EXPRESSION /script/immich_auto_album.sh > /proc/1/fd/1 2>/proc/1/fd/2"
# Reset crontab
crontab -r
(crontab -l 2>/dev/null; echo "$CRONTAB") | crontab -

# Make environment variables accessible to cron
printenv > /etc/environment
fi
fi

0 comments on commit 6e03f20

Please sign in to comment.