Guide

Cron jobs on a VPS

Last updated: 15 November 2026

Cron runs commands on a schedule: backups, cleanups, reports, renewals. It is installed on almost every server. The usual problems are a wrong schedule, a command that works in your shell but not in cron, and no log to tell you it failed. If you are logged in as root, leave out sudo.

Fast VPS from $7.99 a month

See Fast VPS plansHow ordering works

The schedule

Edit your own jobs with crontab -e (list them with crontab -l). A line has five time fields and a command:

# minute hour day-of-month month day-of-week  command
# every day at 03:30
30 3 * * * /home/alice/backup.sh
# every 15 minutes
*/15 * * * * /home/alice/check.sh
# Mondays at 04:00
0 4 * * 1 /home/alice/weekly.sh

Cron uses the server's time zone, often UTC: check it with date.

Avoid the traps

A safe example

0 2 * * * /usr/bin/flock -n /tmp/backup.lock /home/alice/backup.sh >> /home/alice/backup.log 2>&1

Check that it ran: tail /home/alice/backup.log and sudo grep CRON /var/log/syslog (on systems without that file use sudo journalctl -u cron, or -u crond on AlmaLinux and Rocky). Test the schedule by temporarily setting it to every minute.

Related

Back up what matters: backups with restic. Keep long programs alive: tmux. First login · Fast VPS

Questions and answers

How do I schedule a job with cron?
Run crontab -e and add a line with five time fields followed by the command, for example 30 3 * * * /home/alice/backup.sh for every day at 03:30.

Why does my command work in the shell but not in cron?
Cron has a short PATH and no login environment. Use full paths for the program and the script, or set PATH at the top of the crontab.

How do I see whether a cron job ran?
Log its output with >> file 2>&1 and check the cron lines in the system log or journalctl -u cron (crond on AlmaLinux and Rocky).

Which time zone does cron use?
The server's time zone, often UTC; check it with the date command.

Ready to try it? Fast VPS from $7.99 a month

See Fast VPS plansHow ordering works