Saturday, January 27, 2024

[SOLVED] Running a cron job on Linux every six hours

Issue

How can I run command every six hours every day?

I tried the following, but it did not work:

/6 * * * * *  mycommand
id='dv3'>

Solution

You forgot a *, and you've too many fields. It's the hour you need to care about

0 */6 * * * /path/to/mycommand

This means every sixth hour starting from 0, i.e. at hour 0, 6, 12 and 18 which you could write as

0 0,6,12,18 * * * /path/to/mycommand


Answered By - nos
Answer Checked By - Cary Denson (WPSolving Admin)