Chapter 18. Scheduling Commands to run in the background

There are two main tools used to perform scheduled tasks, at and cron. You may also like to try anacron if your computer does not run continuously, as cron will only work if your computer is left on (anacron can catch up with the scheduled tasks the next time the computer is on...).

at

'at' executes a command once on a particular day, at a particular time. at will add a particular command to be executed.

Examples:

at 21:30

You then type the commands you want executed then press the end-of-file key (normally CTRL-D ). Also try:

at now + time

This will run at the current time + the hours/mins/seconds you specify (use at now + 1 hour to have command(s) run in 1 hour from now...)

You can also use the -f option to have at execute a particular file (a shell script).

at -f shell_script now + 1 hour

This would run the shell script 1 hour from now.

atq

Will list jobs currently in queue for the user who executed it, if root executes at it will list all jobs in queue for the at daemon. Doesn't need or take any options.

atrm

Will remove a job from the 'at' queue.

Command syntax:

atrm job_no

Will delete the job “job_no” (use atq to find out the number of the job)

cron

cron can be used to schedule a particular function to occur every minute, hour, day, week, or month.

It's normal to use the crontab to perform the editing functions as this automates the process for the cron daemon and makes it easier for normal users to use cron.

TipAnacron
 

anacron is another tool designed for systems which are not always on, such as home computers

While cron will not run if the computer is off, anacron will simply run the command when the computer is next on (it catches up with things).

crontab

crontab is used to edit, read and remove the files which the cron daemon reads.

Options for crontab (use crontab -option(s)):

  • -e --- to edit the file.

  • -l --- to list the contents of the file.

  • -u username --- use the -u with a username argument to work with another users crontab file.

When using crontab -e you have a number of fields (6) what they mean is listed below:

Field

Allowed Values

minute

0-59

hour

0-23

day of month

1-31

month

1-12 (or names, see below)

day of week

0-7 (0 or 7 is Sun, or use three letter names)

There are also a number of shortcut methods for common tasks, including:[1]

  • @reboot --- run command at reboot

  • @yearly --- same as 0 0 1 1 a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm

  • @annually --- same as @yearly

  • @monthly --- same as 0 0 1 a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm

  • @weekly --- same as 0 0 a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm 0

  • @daily --- same as 0 0 a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm

  • @midnight --- same as @daily

  • @hourly --- same as 0 a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm

[2]

Note that a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm (asterisk) is used to mean anything (similar to the wildcard). For example if you leave the day part (the 5th place) with an asterisk it would mean everyday.

Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12”.

Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to say ``every two hours'', just use ``*/2''.

When writing a crontab entry you simply type in six fields separated by spaces, the first five are those listed in the table (using numbers or letters and numbers as appropriate), the 6th field is the command to be executed and any options, cron will read everything up until the newline.

Example:

5 4 a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm a12264.htm a12264.html b12722.htm backing-up-files.html book1.htm c10407.htm c10694.htm c107.htm c10866.htm c1089.htm c11270.htm c11412.htm c1195.htm c2086.htm c2269.htm c2690.htm c4268.htm c4975.htm c6239.htm c6435.htm c8113.htm c8319.htm c9295.htm c962.htm c9978.htm checking-the-hard-disk.html command-substitution.html compression.html concept-definitions.html contributors.html controlling-processes.html controlling-services.html controlling-the-system.html conventions.html date-time-calendars.html directing-input-ouput.html disclaimer.html doc-index.html duplicating-disks.html feedback.html file-permissions.html finding-information.html finding-packages-tools.html finding-text-within-files.html further-reading.html general-shell-tips.html gnu-free-documentation-licence.html GNU-Linux-Tools-Summary.html graphics-tools.html hard-disk-partition-info.html help.html i12910.htm icon_smile.png index.html internet-specific-commands.html introduction.html legal.html license.html managing-users.html mass-rename.html mathematical-tools.html mini-guides.html miscellaneous.html mounting-and-unmounting.html network-commands.html network-configuration.html other-key-combinations.html performing-more-than-one-command.html references.html remote-administration.html resources-used-to-create-this-document.html rpm.html rsync.html scheduling.html security.html shell-tips.html shutting-down.html some-basic-security-tools.html sources-of-document.html tar.html text-editors.html text-filter-tools.html text-information-tools.html text-manipulation-tools.html text-related-tools.html text-viewing-tools.html the-command-line-history.html the-unix-tools-philosophy.html usage-input-output.html users-and-groups.html using-filesystem.html virtual-terminals.html who-would-not-want-to-read-this-guide.html who-would-want-to-read-this-guide.html wildcards.html working-files-folders.html working-with-ms-dos.html working-with-the-file-system.html x10099.htm x10181.htm x1039.htm x11569.htm x11606.htm x11655.htm x12429.htm x12637.htm x1712.htm x1877.htm x2005.htm x2361.htm x2563.htm x2622.htm x299.htm x3289.htm x335.htm x392.htm x4055.htm x4892.htm x5152.htm x5368.htm x6066.htm x611.htm x6546.htm x662.htm x6823.htm x696.htm x6993.htm x7619.htm x7969.htm x8751.htm x9094.htm x9543.htm sun echo "run at 5 after 4 every sunday"

This would run the echo command with the string shown at 4:05 every Sunday.

Notes

[1]

This information has come from (without editing) a post on the LinuxChix techtalk mailing list, please see [16] in the Bibliography for further information.

[2]

This information comes from the cron manual page with small additions (no changes to original content), refer to [13] in the Bibliography for further information.