cron

Dexter wants to master the usage of the cron command for his upcoming RHEL-based LFCS exam. Please give him a high level overview of the top 3 things he needs to know about cron with examples.

Sure, here are the top 3 things Dexter needs to know about cron:

  1. Cron syntax: Cron uses a specific syntax to define the time and frequency of the tasks to be executed. The syntax consists of five fields, separated by spaces: minute (0-59), hour (0-23), day of the month (1-31), month (1-12), and day of the week (0-6, where Sunday is 0). The following example runs a command every day at 2:30 AM:
    • 30 2 * * * /path/to/command
  2. Scheduling jobs in cron: To schedule jobs in cron, users can edit their own crontab file using the crontab -e command. The crontab file contains lines of commands or scripts to be executed, each followed by the time and frequency using cron syntax. Here's an example to run a script every Monday at 1:00 PM:
    • 0 13 * * 1 /path/to/script
  3. Cron commands: Users can manage their cron jobs using the crontab command, which has a few useful subcommands. The crontab -l command lists the user's current crontab file, crontab -r removes the user's crontab file, and crontab -u is used to manage the crontab file of another user. Here's an example of how to remove a user's crontab file:
    • crontab -r

By understanding the syntax, scheduling, and management of cron jobs, Dexter can effectively use cron to schedule and automate tasks in his RHEL system.

 

You should also read:

crontab and cron

Bird is a RHEL Sysadmin at Google, a really good one. He is teaching two new hires about cron and crontab. He wants…

cron and crontab

Charlier "Bird" Parker is a genius-level saxophonist who has memorized every Linux command in about 2 hours. After a 10 minute interview at…

/var/log/cron

Sonny Stitt is a phenomenal alto saxophonist by night, and a RHEL Systems Manager at Red Hat (Chicago campus) by day. His teams…

cron

Delta is a RHEL Sysadmin at IBM. She has written a script called backup.sh. She wants to create a cron job to run…