Cron job

August 25th, 2006 mysurface Posted in Admin, crontab | Hits: 20653 | 2 Comments »

The script you want it to run every week, hour, day etc, or maybe a single command, you can use crontab or simply put your scripts on certain cron directory.

There are more simple cron directory in /etc.


You can simple copy a script into these folder, make sure you change your script’s mode to be executable. To know what time, all your scripts in the directories to be executed, you must look at /etc/crontab

You will see it contains value such as:


# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

Observer the value at bellow the comment # run-parts. There are 5 column to indicate the time and all jobs run by root. The field shows at bellow:

minute hour day month weekday root run-parts /etc/cron...

So the first line, means the first minute of every hour run all the scripts in /etc/cron.hourly. Second line is actually means that all scripts in /etc/cron.daily will run at 4:02am everyday. * actually means every.
If you want to run some command in specific time, besides that, you can specified in /etc/cron.d , create a file with writting a line ( 5 columns specified time) root command and its parameter, such as

*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok

This command is used to run mrtg in every 5 minutes, which the command line is very long. * means every minute, */5 means every 5 minutes.

Another alternatives, you can insert an cron schedule by :

crontab -e

You can specified this with 5 columns specified times and follow with the command and parameters, without specified root, because if you run crontab -e as root, it is understood that it will be run by root. The cron file will be store at


An example:

0 0 * * 1 /usr/local/bro/etc/bro.rc --checkpoint

Every Monday 0:00am run the command

2 Responses to “Cron job”

  1. [...] The better and easy way should be using at or crontab. I have tried but it doesn’t seems to be working. [...]

  2. Hi there every one, here every one is sharing these know-how,
    thus it’s pleasant to read this weblog, and I used to
    pay a visit this website all the time.

Leave a Reply