CmdKeys LogoCommand Quiz

Cron Command Practice

cron runs commands on a schedule defined by a five-field expression (minute hour day month weekday). This track drills the expression syntax — step, range, and day-of-week selectors — plus the crontab management commands you type to edit, list, and remove schedules without a GUI.

Command Reference

schedule

CommandDescription
0 * * * * <command>Run a command at the start of every hour (minute 0).
*/15 * * * * <command>Run a command every 15 minutes.
15 2 * * * <command>Run a command at 2:15 AM every day.
* * * * * <command>Run a command every minute.
0 */2 * * * <command>Run a command every 2 hours at the top of the hour.
10 9 * * 5 <command>Run a command at 9:10 AM every Friday (day-of-week 5).
0 0 * * 0 <command>Run a command at midnight every Sunday (day-of-week 0).
0 0 1 * * <command>Run a command at midnight on the 1st day of every month.
0 0 1 1 * <command>Run a command at midnight on January 1st each year.
0 9 * * 1-5 <command>Run a command at 9 AM every weekday (Monday through Friday).
15 2 * * 1L <command>Run a command at 2:15 AM on the last Monday of every month.
15 0 * * 4#2 <command>Run a command at 00:15 AM on the second Thursday of every month.

manage

CommandDescription
crontab -eOpen the current user's crontab file in the default editor, creating it if it doesn't exist.
crontab -rRemove the current user's entire crontab file.
crontab -lPrint the current user's crontab entries to stdout.
crontab -vDisplay the timestamp of the last time the current user's crontab was edited.
sudo crontab -e -u <user>Open a specific user's crontab file for editing (requires root).
crontab <file>Replace the current user's crontab with the contents of a file.

special

CommandDescription
@yearly <command>Run a command once per year on Jan 1st at midnight — equivalent to '0 0 1 1 *'.
@reboot <command>Run a command once at system startup.
@hourly <command>Run a command once every hour — equivalent to '0 * * * *'.
@daily <command>Run a command once per day at midnight — equivalent to '0 0 * * *'.
@weekly <command>Run a command once per week on Sunday at midnight — equivalent to '0 0 * * 0'.
@monthly <command>Run a command once per month on the 1st at midnight — equivalent to '0 0 1 * *'.
sudo crontab -r -u <user>Remove another user's crontab file (requires root).
sudo crontab -l -u <user>List the crontab entries for a specific user (requires root).

Key Use Cases

  • Run a backup script at 2:15AM every night
  • Trigger a health check every 15 minutes
  • Schedule a job for the last Monday of each month
  • Edit or list the current user's crontab
  • Use @daily or @reboot instead of writing the full five fields
  • Edit another user's crontab with sudo

Frequently Asked Questions

What does */15 mean in a cron field?

The slash is a step. */15 in the minute field means 'every 15 minutes starting at 0' — i.e., at :00, :15, :30, :45. Without the *, writing 15 alone would only match minute 15.

What is the difference between @daily and @midnight?

They are identical — both expand to '0 0 * * *'. @midnight is an alias kept for backward compatibility. Either is accepted here.

Does cron use 0 or 7 for Sunday?

Both 0 and 7 are accepted for Sunday in the day-of-week field on most cron implementations. This track uses 0 to stay consistent with the POSIX definition.

How do I stop a cron job from running?

crontab -r removes your entire crontab. To remove a single job, use crontab -e, delete the line, and save — there is no flag to remove a single entry non-interactively.

Ready to master Cron commands?

Test your muscle memory with our spaced-repetition quiz system. Free forever.

Start Practice Now →