O'Reilly logo

Fedora Linux by Chris Tyler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scheduling Tasks

Fedora Core can schedule tasks to be run at specific times. This is useful for making backups, indexing data, clearing out temporary files, and automating downloads— and it’s easy to set up.

How Do I Do That?

To schedule a task, use crontab with the -e option to edit your list of scheduled tasks:

$ crontab -e

The vi editor will start up, and any existing scheduled tasks will appear (if you don’t have any scheduled tasks, the document will be blank). Edit the file using standard vi editing commands.

Each scheduled task occupies a separate line in this file. Each line consists of five time fields, followed by the command to be executed. In order, the file fields are:

minute

The number of minutes past the hour, 0–59

hour

The hour of the day, 0–23

day

The day of the month, 1–31

month

The number of the month, 1–12

day of the week

The day of the week, 0–6 (Sunday to Saturday) or 1–7 (Monday to Sunday), or written out

A time field may contain an asterisk, which means any.

Here is an example:

30 * * * *    /home/chris/bin/task1

The script or program /home/chris/bin/task1 will be executed at 30 minutes past the hour, every hour of every day of every month. Here are some other examples:

15 1 * * *    /home/chris/bin/task2
0 22 * * 1    /home/chris/bin/task3
30 0 1 * *    /home/chris/bin/task4
0 11 11 11 *  /home/chris/bin/task5

task2 will be executed at 1:15 a.m. every day. task3 will be executed at 10:00 p.m. every Monday. task4 will be run at 12:30 a.m. on the first of every month. task5 will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required