[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 [2013/10/17 00:18 (UTC)] – uncommented links to non-existent articles and added a note asking or contributions mfillpot | 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 10: | Line 10: | ||
* '' | * '' | ||
- | < | + | =====Using at===== |
- | The links in red are to non-existent articles. | + | 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, |
- | If you are experienced | + | < |
+ | 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> < | ||
+ | job 4 at 2015-06-22 12:01 | ||
+ | darkstar:~% | ||
+ | </ | ||
+ | |||
+ | =====File-driven at===== | ||
+ | Commands can also be contained within a file and run by **// | ||
+ | < | ||
+ | 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. | ||
+ | |||
+ | < | ||
+ | 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===== | ||
+ | |||
+ | **// | ||
+ | |||
+ | **// | ||
+ | |||
+ | < | ||
+ | darkstar:~% crontab -e | ||
+ | </ | ||
+ | |||
+ | To edit the system-level // | ||
+ | |||
+ | < | ||
+ | darkstar:~# crontab -e | ||
+ | </ | ||
+ | |||
+ | If your system has **// | ||
+ | |||
+ | < | ||
+ | darkstar:~% sudo crontab -e | ||
+ | </ | ||
+ | |||
+ | The //crontab// file syntax is: | ||
+ | |||
+ | < | ||
+ | # * * * * * 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) | ||
+ | # │ │ └─────────────── day of month (1 - 31) | ||
+ | # │ └──────────────────── hour (0 - 23) | ||
+ | # └───────────────────────── min (0 - 59) | ||
+ | </ | ||
+ | |||
+ | Using an asterisk in any placeholder location, will match any value. For example, the following will run // | ||
+ | |||
+ | < | ||
+ | #For more information see the manual pages of crontab(5) and cron(8) | ||
+ | # | ||
+ | # min hr day month weekday command | ||
+ | # | ||
+ | # | ||
+ | |||
+ | 0 11 * 1-3 * / | ||
+ | </ | ||
+ | |||
+ | =====Using anacron===== | ||
+ | < | ||
+ | **// | ||
</ | </ | ||
+ | |||
+ | **// | ||
====== Sources ====== | ====== Sources ====== | ||
Line 21: | Line 119: | ||
<!-- Authors are allowed to give credit to themselves! --> | <!-- Authors are allowed to give credit to themselves! --> | ||
* 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> | ||
+ |