Files
public-setupfiles/repo_automation/cron-job-setup-files/setup_cron_job_updates.sh
T

28 lines
1.0 KiB
Bash
Raw Normal View History

2023-08-22 14:52:29 -05:00
#!/bin/bash
# Script: setup_auto_updates.sh
# Description: Script to set up automatic system updates using cron
# Update package lists and install cron
2023-01-29 18:14:14 -06:00
sudo apt update
2023-08-22 14:52:29 -05:00
sudo apt install cron -y
# Enable and start the cron service
2023-01-29 18:14:14 -06:00
sudo systemctl enable cron
2023-08-22 14:52:29 -05:00
sudo systemctl start cron
# Stop the cron service to make changes
2023-01-29 18:14:14 -06:00
sudo systemctl stop cron
2023-08-22 14:52:29 -05:00
# Add the update and upgrade cron job to /etc/cron.d/
2023-09-06 14:12:32 -05:00
# 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
2025-01-23 14:04:49 -06:00
# 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
0 */1 * * * root mount -a' | sudo tee /etc/cron.d/auto_updates
2023-01-29 18:14:14 -06:00
2023-08-22 14:52:29 -05:00
# Restart the cron service to apply the new cron job
sudo systemctl start cron