Cronjobs

cron is a time-based scheduling service in Linux / Unix-like computer operating systems.

$ crontab -u (username) -e

=======================

# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (1 - 12)
# | | | | +---- day of week (0 - 6) (Sunday=0 or 7)
# | | | | |

* * * * * command to be executed
=============================
Minute :

* = every minute

*/5 = after every five minutes

15 = After 15 minutes



Hour :

0 = midnight

4 = 4 AM

23 = 11 PM



Day :

1 = 1st day of the month

5 = 5th day of the month

31 = 31st day of the month



Month :



1 = Month of the year (January = 1 , February = 2 and so on ... )



Weekday :



0 = Day of the week (Sunday = 0, Monday = 1, Tuesday = 2 and so on ...)

Cron Job examples :



If you want a cron job to run at 5:00 and 10:00 A.M then you can set it like:



Code:
* 5,10 * * *  /usr/local/bin/php -q /home/cpanelusername/public_html/path of your cron file
If you want to set the cron job every day at midnight then it would be like:

Code:
0 0 * * * /usr/local/bin/php -q /home/cpanelusername/public_html/path of your cron file
Similarly ,

If you want to set the cron job from Monday to Friday at midnight then it would be like:

Code:
0 0 * * 1,2,3,4,5 /usr/local/bin/php -q /home/cpanelusername/public_html/path of your cron file

Now you can easily setup your own cron jobs.Cheers .....

EnjoyWink




    0 comments: