Bookmark this page

Practice: Scheduling Recurring Jobs with cron

In this lab, you will schedule a recurring job using cron.

Resources
Machines: desktopX

Outcomes

A recurring job is scheduled, and then removed again.

  1. Log into your desktopX machine as student.

  2. Schedule a recurring job that...

    • ...runs as your student user.

    • ...runs every two minutes between 09:00 and 16:59 on Monday to Friday.

    • ...appends the current date and time to the file /home/student/my_first_cron_job.

    1. Start the crontab editor.

      [student@desktopX ~]$ crontab -e
    2. Insert the following line:

      */2 9-16 * * 1-5 date >> /home/student/my_first_cron_job
    3. Save your changes and quit the editor (:wq).

  3. Inspect all of your scheduled cron jobs.

    1. [student@desktopX ~]$ crontab -l
  4. Wait for your job to run at least once or twice, then inspect the contents of the /home/student/my_first_cron_job file.

    1. [student@desktopX ~]$ cat ~/my_first_cron_job
  5. Remove all of the cron jobs for student.

    1. [student@desktopX ~]$ crontab -r
Revision: rh134-7-c643331