add_cron() {
local entry="$1"
# Read current crontab (empty if none), add the line if missing
if ! crontab -l 2>/dev/null | grep -qF -- "$entry"; then
(crontab -l 2>/dev/null; echo "$entry") | crontab -
echo "Added: $entry"
else
echo "Already present: $entry"
fi
}
add_cron "0 3 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1"
add_cron "*/5 * * * * /usr/local/bin/health-check.sh"
# Remove a cron entry by pattern
crontab -l | grep -v 'backup.sh' | crontab -
# Show current crontab
crontab -l
Create a free account and build your private vault. Share publicly whenever you want.