Create setup_cron_job_updates-nomount.sh

This commit is contained in:
WickedYoda committed 2025-01-30 12:28:27 -06:00
1 parent 3910d808ca
commit 79be0e2d40
1 file changed
+27
@@ -0,0 +1,27 @@
#!/bin/bash
# Script: setup_auto_updates.sh
# Description: Script to set up automatic system updates using cron
# Update package lists and install cron
sudo apt update
sudo apt install cron -y
# Enable and start the cron service
sudo systemctl enable cron
sudo systemctl start cron
# Stop the cron service to make changes
sudo systemctl stop cron
# Add the update and upgrade cron job to /etc/cron.d/
# Old line that doesnt work
# echo 'MAILTO="alerts@tyates.one"
# 0 */6 * * * root apt-get update && apt-get -y -d full-upgrade && apt-get autoremove -y && sudo apt-get clean -y && sudo apt-get purge -y' | sudo tee /etc/cron.d/auto_updates
# Add the update and upgrade cron job to /etc/cron.d/auto_updates
echo 'MAILTO="alerts@tyates.one"
0 */6 * * * root apt-get update && apt-get -y -d full-upgrade && apt-get autoremove -y && sudo apt-get clean -y && sudo apt-get purge -y' | sudo tee /etc/cron.d/auto_updates
# Restart the cron service to apply the new cron job
sudo systemctl start cron