Automating VPS Tasks with cron and systemd Timers

Automating VPS Tasks with cron and systemd Timers

Automation reduces human error and keeps your VPS running smoothly.

Using cron (Classic Method)

Create or Edit Cron Jobs

crontab -e

Example: Daily Backup at 2 AM

0 2 * * * /root/backup.sh

Using systemd Timers (Modern & Recommended)

Create a Service File

nano /etc/systemd/system/backup.service

Create a Timer File

nano /etc/systemd/system/backup.timer

Enable the timer:

systemctl enable --now backup.timer

Tip:
systemd timers provide better logging and error handling than cron.