#!/bin/sh # Adds the watchdog (every 5 min), backup (04:40) and daily restart (05:00) to your crontab. # Safe to run again: replaces its own lines (tagged with this folder's path), leaves others alone. # ./scripts/install-cron.sh --remove takes them out again. D=$(cd "$(dirname "$0")/.." && pwd) TAG="# ql-lg-server $D" OLD=$(crontab -l 2>/dev/null | grep -vF "$TAG") if [ "$1" = "--remove" ]; then printf '%s\n' "$OLD" | crontab - && echo "removed cron lines for $D"; exit 0 fi { [ -n "$OLD" ] && printf '%s\n' "$OLD" echo "*/5 * * * * $D/scripts/watchdog.sh $TAG" echo "40 4 * * * $D/scripts/backup.sh $TAG" echo "0 5 * * * $D/scripts/daily-restart.sh $TAG" } | crontab - echo "cron installed for $D:"; crontab -l | grep -F "$TAG"