[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
howtos:general_admin:task_scheduling [2015/06/23 20:36 (UTC)] – Started editing an example of using cron and crontab tdrssb | howtos:general_admin:task_scheduling [2015/06/24 19:36 (UTC)] (current) – tdrssb | ||
---|---|---|---|
Line 3: | Line 3: | ||
====== Task Scheduling in Linux ====== | ====== Task Scheduling in Linux ====== | ||
=====Overview===== | =====Overview===== | ||
- | This article discusses some tools used in a Linux system to schedule tasks to run automatically at specified time intervals or at any given point of time in the future. | + | This article discusses some tools used in a Linux system to schedule tasks to run automatically at specified time intervals or at any given point of time in the future. This primer will not cover these commands in-depth; this is just a brief introduction to using these commands. See the individual HOWTOS for each command for an in-depth look at all relevant options and configurations. |
Some task-scheduling daemons used in Linux/UNIX are: | Some task-scheduling daemons used in Linux/UNIX are: | ||
Line 9: | Line 9: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
+ | =====Using at===== | ||
+ | The **//at//** command allows a user to execute commands or scripts at a specified time (required) and date (optional). The commands can be entered via standard input, redirection, | ||
+ | |||
+ | < | ||
+ | darkstar:~% at | ||
+ | </ | ||
+ | |||
+ | =====Interactive at===== | ||
+ | Using the command **//at//** with standard input (keyboard) is a little more complicated than typing one line in at the prompt. The command uses an internal " | ||
+ | |||
+ | < | ||
+ | darkstar:~% at 12:01 -m | ||
+ | warning: commands will be executed using (in order) a) $SHELL b) login shell c) /bin/sh | ||
+ | at> ./ | ||
+ | at> <EOT> | ||
+ | job 4 at 2015-06-22 12:01 | ||
+ | darkstar: | ||
+ | </ | ||
+ | |||
+ | =====File-driven at===== | ||
+ | Commands can also be contained within a file and run by **//at//**: | ||
+ | < | ||
+ | darkstar:~% at 12:32 -m -f / | ||
+ | warning: commands will be executed using (in order) a) $SHELL b) login shell c) /bin/sh | ||
+ | job 8 at 2015-06-22 12:10 | ||
+ | </ | ||
+ | The **-m** flag will email the user after completion of the command; the **-f** flag specifies the command will read the job from a file, not from standard input. After the command is typed in (and the appropriate warning is displayed), the **//at//** job number((As distinct from a process ID (PID) known to the operating system)) is displayed. | ||
+ | |||
+ | =====at Internal Scheduling===== | ||
+ | The job numbers provided after a command is typed in, or when a file is read, allow the user to know which internal job will be run in sequential order. If a user wants to delete a specific task, all that needs to be known is this internal job number. To remove the job, the command **// | ||
+ | |||
+ | < | ||
+ | darkstar: | ||
+ | 7 2015-06-22 12:10 p tux | ||
+ | 8 2015-06-22 12:15 p root | ||
+ | </ | ||
+ | |||
+ | The command **//atq//** (**__at__ __q__ueue**) is the same as **//at -l//**: | ||
+ | |||
+ | < | ||
+ | darkstar: | ||
+ | 7 2015-06-22 12:10 p tux | ||
+ | 8 2015-06-22 12:15 p root | ||
+ | </ | ||
+ | |||
+ | To remove the user job, use **// | ||
+ | < | ||
+ | darkstar: | ||
+ | </ | ||
=====Using cron===== | =====Using cron===== | ||
Line 34: | Line 84: | ||
The //crontab// file syntax is: | The //crontab// file syntax is: | ||
- | minute(0-59) hour(0-23) day(1-31) | + | < |
+ | # * * * * * command to execute | ||
+ | # │ │ │ │ │ | ||
+ | # │ │ │ │ │ | ||
+ | # │ │ │ │ └───── day of week (0 - 6) (Sun(0) /Mon (1)/Tue (2)/Wed (3)/Thu (4)/Fri (5)/Sat (6)) | ||
+ | # │ │ │ └────────── month (1 - 12) | ||
+ | # │ │ └─────────────── | ||
+ | # │ └──────────────────── hour (0 - 23) | ||
+ | # └───────────────────────── min (0 - 59) | ||
+ | </ | ||
Using an asterisk in any placeholder location, will match any value. For example, the following will run // | Using an asterisk in any placeholder location, will match any value. For example, the following will run // | ||
Line 48: | Line 107: | ||
</ | </ | ||
- | + | =====Using anacron===== | |
< | < | ||
- | The links in red are to non-existent articles. | + | **// |
- | + | ||
- | If you are experienced with those tools, please feel free to write the articles. | + | |
</ | </ | ||
+ | |||
+ | **// | ||
====== Sources ====== | ====== Sources ====== | ||
Line 62: | Line 120: | ||
* Originally written by [[wiki: | * Originally written by [[wiki: | ||
* Contrbutions by [[wiki: | * Contrbutions by [[wiki: | ||
+ | * Example crontab example modified from [[en.wikipedia.org/ | ||
<!-- Please do not modify anything below, except adding new tags.--> | <!-- Please do not modify anything below, except adding new tags.--> | ||
<!-- You must also remove the tag-word " | <!-- You must also remove the tag-word " | ||
{{tag> | {{tag> | ||
+ |