crontab command

We can use crontab to arrange some task running in the background so in some hour or minute it will run.
just do in root priviledge for root task, or not for user task. (remember the user task has a limitation on the command that he can accessed)

$nano crontab -e
for editing the crontab. in Ubuntu we will be asked whether to use nano editor or vi or vim. In Slackware it will use simple vi editor. And we need extra knowlege about how to use vi editor command.
Here are the rule of the crontab :
* * * * * command
0 */3 * * * (every three hour)
0 * * * * (every hour)
The first * is represent the minute (value * = any minute, 0 to 59)
The 2nd * is represent the hour (value * = any hour, 0 to 24)
The 3rd * is represent the day of month (1-31)
The 4th * is represent the month (1-12)
The 5th * is represent the day of week (0-6, 0=sunday)

* * * * * command to be executed
– – – – –
| | | | |
| | | | +—– day of week (0 – 6) (Sunday=0)
| | | +———- month (1 – 12)
| | +————— day of month (1 – 31)
| +——————– hour (0 – 23)
+————————- min (0 – 59)

Example :
* 2 * * * /sbin/telinit 0 > /dev/null
This is mean the computer will be shut down at 2 a.m everyday.
15 2 * * * /sbin/telinit 0 > /dev/null
This is mean the computer will be shut down at 2.15 a.m every day

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.