OSVauco/remove_cron_debug3.sh

32 lines
775 B
Bash
Executable File

#!/bin/bash
# set -euo pipefail
exec > ~/OSVauco/debug_output.log 2>&1
BACKUP="$HOME/crontab.backup.$(date +%F-%H%M%S)"
crontab -l > "$BACKUP"
TMP="$(mktemp)"
grep -vE 'OSVauco/scripts/vm-teardown\.sh|secret=webhook-url.*(teardown|VM kjører)' "$BACKUP" > "$TMP"
echo "--- Content of temp file ---"
cat "$TMP"
echo "---------------------------"
crontab "$TMP"
# rm -f "$TMP" # Keep the temp file for debugging
echo "Backup saved: $BACKUP"
echo
echo "Resulting crontab:"
crontab -l | nl -ba
echo
echo "Verification:"
if crontab -l | grep -Ei 'vm-teardown\.sh|teardown|VM kjører'; then
echo "ERROR: A related entry is still present; do not make further changes automatically."
exit 1
else
echo "OK: No VM teardown or teardown-warning cron entries remain."
fi