Skip to content
Advertisement

How do you execute cron job every 5 minutes?

JavaScript

I am trying to execute a Cron Job every 5 minutes of an hour but its not executing on time. I think that the time expression is wrong.

How do you set the time expression for a 1, 5 minute job and a 2 for 1 hour job?

Advertisement

Answer

For job 1, 5 minute, you can use:

JavaScript

Because the first field is for minutes. If you specify * in this field, it runs every minutes. If you specify */5 in the 1st field, it runs every 5 minutes as shown above.

For job 2, 1 hour, you can use:

JavaScript

Because the second field is for hours. If you specify * in this field, it runs every hour. If you specify */5 in the 2nd field, it runs every 5 hours as shown above.

Not related with cron but your code seems to be missing to pass expression as to TheLostMind comment.

Correct sentence For job 1:

JavaScript

Hope it helps.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement