Difference between revisions of "Crontab Add"

From MS Computech
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
'''Crontab Add type'''
 
'''Crontab Add type'''
<pre>crontab -e </pre><pre>0-59 * * * * /usr/bin/iptrafvol.pl -l </pre>
+
 
 +
<pre>
 +
1: Minute (0-59)
 +
2: Hours (0-23)
 +
3: Day (0-31)
 +
4: Month (0-12 [12 == December])
 +
5: Day of the week(0-7 [7 or 0 == sunday])
 +
/path/to/command – Script or command name to schedule
 +
Easy to remember format:
 +
 
 +
# .---------------- minute (0 - 59)
 +
# |  .------------- hour (0 - 23)
 +
# |  |  .---------- day of month (1 - 31)
 +
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
 +
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
 +
# |  |  |  |  |
 +
# *  *  *  *  * user-name  command to be executed
 +
 
 +
* * * * * command to be executed
 +
 
 +
# | | | | |
 +
# | | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
 +
# | | | ------- Month (1 - 12)
 +
# | | --------- Day of month (1 - 31)
 +
# | ----------- Hour (0 - 23)
 +
# ------------- Minute (0 - 59)
 +
</pre>
 +
Example
 +
Run every minute.
 +
<pre>crontab -e </pre>
 +
<pre>* * * * * /usr/bin/iptrafvol.pl -l </pre>
 +
Run every midnight
 +
<pre>0 0 * * * /path/to/command</pre>
 +
Run every 2 AM
 +
<pre>0 2 * * *  /usr/sbin/ccsquid</pre>
 +
30 minute after 3 AM
 +
<pre>30 3 * * *  /usr/sbin/ccsquid</pre>

Latest revision as of 09:58, 30 March 2016

Crontab Add type

1: Minute (0-59)
2: Hours (0-23)
3: Day (0-31)
4: Month (0-12 [12 == December])
5: Day of the week(0-7 [7 or 0 == sunday])
/path/to/command – Script or command name to schedule
Easy to remember format:

# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

* * * * * command to be executed

# | | | | |
# | | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
# | | | ------- Month (1 - 12)
# | | --------- Day of month (1 - 31)
# | ----------- Hour (0 - 23)
# ------------- Minute (0 - 59)

Example Run every minute.

crontab -e 
* * * * * /usr/bin/iptrafvol.pl -l 

Run every midnight

0 0 * * * /path/to/command

Run every 2 AM

0 2 * * *  /usr/sbin/ccsquid

30 minute after 3 AM

30 3 * * *  /usr/sbin/ccsquid