Overview

Crontab servers for jobs scheduling. In a nutshell, administrators put script there which they want to be executed at specific time or in specific frequency. As such crontab is suitable for:

Configuration

Configuration of crontab is fairly simply if we remember couple things. First let's check the syntax:

*     *     *   *    *        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)

Having seen that, a job in crontab will look as follows:

Example

30     18     *     *     *         rm /tmp/* >> /root/clean.log

This job, will execute each day at 18:30 and will delete everything in the temporary directory, and will write the log in /root/clean.log

In order to create such a job, we have to execute the following:

[root@mysqlmaster ~]# crontab -e <- "e" - stands for Edit
no crontab for root - using an empty one

~
30     18     *     *     *         rm /tmp/* >> /root/clean.log

:wq

To list all the jobs, we can issue the following command:

[root@mysqlmaster ~]# crontab -l
30     18     *     *     *         rm /tmp/* >> /root/clean.log
[root@mysqlmaster ~]#

Crontab configurations are per user, so each user has his own crontab, be sure that your user has the correct permissions to the the job