Schedule System Restart - LeandroTheDev/arch_linux GitHub Wiki
Update and restart system
- sudo vim /usr/local/bin/update_and_reboot.sh
#!/bin/sh
updates=$(pacman -Qu | awk '{print $1}')
if [ -z "$updates" ]; then
echo "No available updates, reboot cancelled"
exit 0
fi
sudo pacman -Syu --noconfirm
if [ $? -ne 0 ]; then
echo "Failed to update the system."
exit 1
fi
echo "Update sucess, rebotting..."
systemctl reboot
- sudo chmod +x /usr/local/bin/update_and_reboot.sh
- sudo vim /etc/systemd/system/update_and_reboot.service
[Unit]
Description=Update Arch Linux and Reboot
[Service]
Type=oneshot
ExecStart=/usr/local/bin/update_and_reboot.sh
- sudo vim /etc/systemd/system/update_and_reboot.timer
[Unit]
Description=Timer for weekly Arch Linux update and reboot
[Timer]
OnCalendar=Tue 20:00:00
Persistent=true
[Install]
WantedBy=timers.target
- sudo systemctl enable --now update_and_reboot.timer