CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Services & Projects

[Operating Systems] Cron - Linux's clockswitch


[Reply] [View by Thread] [Help]
[Back To Article Discussion Forum]

Posted by Author MaDvLaD On 2007-04-29 10:02:29




View and vote on the article here: Cron - Linux's clockswitch


Cron - Linux's clockswitch

Category
Operating Systems
Summary
Body
Cron - Linux's clockswitch

<hr />
The 'cron' package is installed by default on every Linux system and is part of the base package (The "base" software packages required to run a basic Linux installation). It is very useful to handle routinary tasks and processes (maintenance/"clean up" tasks for example), and can execute commands scheduled for any time, specified by its configuration.

Cron runs as a daemon in the background, and is started automatically on every boot-up, though it can also be started manually. It's configuration file (crontab) can be found in /etc and is easy to understand. Cron looks up the configuration file's table every minute to check if there is any tasks that need executed. It should look similar to the following:
# Minute Hour Day Month Weekday Command




 5    22   * * *    test -x /usr/sbin/texpire && /usr/sbin/texpire


 59   23   * * *    /usr/bin/xmessage.sh


 0    0    * * 1    /usr/bin/xmessagedel.sh


 1    0    * * 1    /usr/bin/xsoftwaresamba.sh
You can use the following as a reference:
 Minutes    | 0-59 and * for all Minutes


 Hours      | 0-23 and * for all Hours


 Days       | 1-31 and * for every Day


 Months     | 1-12 and * for every Month


 Week days  | 0-7  and * for every Weekday (0 and 7 for Sunday)
The scheduled tasks can also be seen by issuing the command 'crontab -l', which displays the table in the crontab file.
Well, in the above example... the first two tasks are run daily: the first time at 22:05 and the second at 23:59. The last two tasks are run once per week, at 0:00 and 0:01.


Some more examples:


The script 'xmanager.sh' will be run daily at 0:00 and 12:00:
  0 0,12 * * *  /usr/bin/xmanager.sh
On the fifteenth of every month, 'xmail.sh' will be run at 12:30:


[code]
30 12 15 * * /usr/bin/xmail.sh
</br>[code]




abc.sh will be run every friday at 0:00 o'clock:


[code]
0 0 * * 5 /usr/bin/abc.sh
[code]




Everyday xmail.sh is run from 6-23 o'clock at a 15min interval:
[code]
*/15 6-23 * * * root /usr/bin/xmail.sh
[code]




For further assistance, issue the command 'man crontab' and read the informative man page of cron.


<hr />
Written by: MaDvLaD (9 March 2005)

MaDvLaD is Member Of Community Projects, Planning & Development



This article was imported from the CyberArmy University site. (original author: madvlad)


There are no replies to this post yet.



Guest:
Subject:
Message:
Signature:
Optional Image Link:
http://

CyberArmy::Forum v0.6
Generated In 0.07859 seconds


About Us | Privacy Policy | Mission Statement | Help