How to write CRON jobs
CRON jobs or CRON tasks are very useful for automatizing repetitive work. With cron job help you can for example once a week wipe out cache files in your app directory or send email about number of newly registered users. You can imagine any kind of task which require repetitiveness.
How to set CRON job
For setting frequency of cycles standardized crontab unix form [minutes] [hours] [day] [month] [day in week] is used.
[Minute] [Hour] [Day] [Month] [Day of week] [Command]
- Minutes: 0-59
- Hours: 0-23
- Day of the month: 1-31
- Month: 1-12
- Day of the week: 0-7 (0 and 7 – both represent Sunday)
- Every minute: * * * * *
- Every 5 minutes: */5 * * * *
- Every hour in 30th minute: 30 * * * *
- Every day at midnight: 0 0 * * *
- At Sunday at 12:00:
- 0 12 * * 0
- 0 12 * * 7
- Monday – Friday always at 12:00: 0 12 * * 1,2,3,4,5
Openjs.com offers nice help to quickly set correct time period.