xutil.dev
Login

Cron Expression Cheatsheet

Quick reference for cron syntax covering field syntax, special strings, field values, time examples, system tasks, backup tasks, environment, and troubleshooting

60 commands

* * * * * command

Run every minute (min hour day month weekday)

crontab -e

Edit current user's crontab

crontab -l

List current user's crontab

crontab -r

Remove current user's crontab

crontab -u {user} -e

Edit crontab for specific user

crontab -u {user} -l

List crontab for specific user

/etc/crontab

System crontab file (with user field)

/etc/cron.d/

Additional cron job definition directory

@reboot

Run once at system startup

@yearly / @annually

Run once a year (Jan 1, 00:00)

@monthly

Run once a month (1st, 00:00)

@weekly

Run once a week (Sunday, 00:00)

@daily / @midnight

Run once a day (00:00)

@hourly

Run once an hour (at :00)

* (asterisk)

Match all values

, (comma)

List multiple values

- (hyphen)

Range of values

/ (slash)

Step values (intervals)

分: 0-59

Minute field range

時: 0-23

Hour field range

日: 1-31

Day of month field range

月: 1-12 / JAN-DEC

Month field range

曜日: 0-7 / SUN-SAT

Day of week range (0 and 7 = Sunday)

*/5 * * * *

Run every 5 minutes

*/15 * * * *

Run every 15 minutes

0 * * * *

Run at the start of every hour

0 */2 * * *

Run every 2 hours

0 9 * * *

Run daily at 9:00 AM

0 9-17 * * 1-5

Run hourly 9-17 on weekdays

30 2 * * *

Run daily at 2:30 AM

0 0 * * 0

Run every Sunday at midnight

0 0 1 * *

Run on the 1st of every month

0 0 1 1 *

Run on January 1st every year

*/5 * * * * ... >/dev/null 2>&1

Run and discard output

0 3 * * * ... >> /var/log/cron.log 2>&1

Append output to log file

0 2 * * * apt-get update

Update package list daily at 2 AM

0 4 * * * find /tmp -mtime +7 -delete

Delete temp files older than 7 days

*/10 * * * * /usr/bin/certbot renew

Check SSL certificate renewal

0 6 * * * systemctl restart nginx

Restart Nginx daily at 6 AM

*/2 * * * * /path/to/healthcheck.sh

Run health check every 2 minutes

0 1 * * * mysqldump ...

MySQL backup daily at 1 AM

0 2 * * * pg_dump ...

PostgreSQL backup daily at 2 AM

0 3 * * * tar czf ...

Archive directory daily at 3 AM

0 4 * * * rsync -avz ...

Remote sync backup daily at 4 AM

0 0 * * 0 find /backup -mtime +30 -delete

Delete backups older than 30 days weekly

0 5 * * * aws s3 sync ...

Sync backup to S3 daily at 5 AM

SHELL=/bin/bash

Set cron execution shell

PATH=...

Explicitly set PATH

MAILTO=user@example.com

Set email for cron output

MAILTO=""

Disable cron email output

HOME=/home/user

Set home directory

CRON_TZ=timezone

Set cron timezone

grep CRON /var/log/syslog

Check cron logs

journalctl -u cron

View cron logs via systemd

systemctl status cron

Check cron service status

systemctl restart cron

Restart cron service

run-parts --test /etc/cron.d/

Test-run scripts in cron.d

date

Check server current time

which {command}

Check full path of command

env -i /bin/bash -c 'command'

Test command in minimal environment