cron command to run every 12 hours

A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

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

* in the value field above means all legal values as in braces for that column.

You could use 0 1,13 * * * which means for every 1AM and 1PM.

0 1,13 * * * rm /var/www/*/somedir/index.php > /home/someuser/cronlogs/some.log 2>&1

where * can be replaced by different domain names.


I think the right way is -> 1 */12 * * * (actually, any number in the minute position will do the trick.)

If you set -> * */12 * * * it will be executed every minute at 12h and again at 24h.

Tags:

Unix

Cron