mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-02 13:03:34 +00:00
made the crontab installation safe as opposed to nuking it - spotted by thespad
This commit is contained in:
@@ -160,12 +160,22 @@ fi
|
||||
|
||||
# Setup crontab for automatic package status updates
|
||||
info "⏰ Setting up automatic package status update every $UPDATE_INTERVAL minutes..."
|
||||
|
||||
# Check if patchmon cron job already exists
|
||||
PATCHMON_CRON_EXISTS=$(crontab -l 2>/dev/null | grep -c "patchmon-agent.sh update" || true)
|
||||
|
||||
if [[ $PATCHMON_CRON_EXISTS -gt 0 ]]; then
|
||||
info " Existing PatchMon cron job found, removing old entry..."
|
||||
# Remove existing patchmon cron entries and preserve other entries
|
||||
(crontab -l 2>/dev/null | grep -v "patchmon-agent.sh update") | crontab -
|
||||
fi
|
||||
|
||||
if [[ $UPDATE_INTERVAL -eq 60 ]]; then
|
||||
# Hourly updates
|
||||
echo "0 * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1" | crontab -
|
||||
# Hourly updates - safely append to existing crontab
|
||||
(crontab -l 2>/dev/null; echo "0 * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1") | crontab -
|
||||
else
|
||||
# Custom interval updates
|
||||
echo "*/$UPDATE_INTERVAL * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1" | crontab -
|
||||
# Custom interval updates - safely append to existing crontab
|
||||
(crontab -l 2>/dev/null; echo "*/$UPDATE_INTERVAL * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1") | crontab -
|
||||
fi
|
||||
|
||||
success "🎉 PatchMon Agent installation complete!"
|
||||
|
||||
Reference in New Issue
Block a user