The */5
means "any minute, but every five".
Depending on the implementation, that’s enough
*/5 5-20 * * * php ~/pasta/para/app/artisan queue:work
Syntax of crontab:
* * * * * caminho/comando
│ │ │ │ │
│ │ │ │ └────── em quais dias da semana de 0 a 7 (tanto 0 quanto 7 são Domingo)
│ │ │ └────────── em quais meses (1 - 12)
│ │ └────────────── em quais dias (1 - 31)
│ └────────────────── em quais horas (0 - 23)
└────────────────────── em quais minutos (0 - 59)
Specifying each item:
* Todos
1,2,4 Um, dois e Quatro apenas
7-10 De 7 a 10, incluindo 8 e 9
*/5 A qualquer momento, mas com espaço de 5 (ex: 2,7,12,17...)
1-10/3 No intervalo de 1 a 10, mas de 3 em 3 (ex: 2,5,8)
Note: when you use /n
, depends on when the cron
is updated by the table that the range is counted, therefore, */5
can be either 0,5,10,15 or 1,6,11,16.
An example if it needed to be every 3 hours in that interval:
*/5 5-20/3 * * * php ~/pasta/para/app/artisan queue:work
Remark: the cron
there are no intervals in some implementations (I don’t know if this proceeds in any modern distro yet), you may need to specify all hours:
*/5 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 * * * php ~/pasta/para/app/artisan queue:work
More details in the crontab
:
http://linux.die.net/man/5/crontab
From what I see seems to be an application of Laravel, It would not be easier to use a Schedule and call the command ?
– Bulfaitelo
Laravel was just an example. The tags and the content of the question were in order to understand about cronjob itself
– Wallace Maxters