Skip to content

Commit

Permalink
If cron entry is already present, don't duplicate it.
Browse files Browse the repository at this point in the history
  • Loading branch information
srnjak committed Oct 26, 2023
1 parent 61d9e27 commit a790fd2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ set -e

case "$1" in
configure)
# Add the cronjob to the current user's crontab
(crontab -l 2>/dev/null || true; echo "0 0 * * * /usr/share/purge-backups/purge-backups-scheduler") | crontab -
# Check if the cronjob is already present
if ! crontab -l | grep -q "/usr/share/purge-backups/purge-backups-scheduler"; then
# Add the cronjob to the current user's crontab
(crontab -l 2>/dev/null || true; echo "0 0 * * * /usr/share/purge-backups/purge-backups-scheduler # Part of purge-backups package. DO NOT CHANGE!") | crontab -
else
echo "Cronjob already exists. Skipping addition."
fi
;;
*)
# Do nothing on other actions
Expand Down

0 comments on commit a790fd2

Please sign in to comment.