In your project you might have to run a function or script (.php) file automatically for a various reasons like automatic sending email on birthday or automatically close a auction when the end_time is reached. What to do in that situation? .To do these things automatically, you must have a php file which must contains the code and these files should be called automatically at certain certain time. So how to do that? The answer is Cron Job. Cron job are the cron tab command found in the UNIX or Linux system.
Now let’s see how can we call the file automatically at certain duration. Let’s suppose the duration is one hour, now I’ll show you how to setup the the cron-job of every one hour to run a PHP file automatically in the Cpanel of your website.
- Go to the Cpanel of your website.
- Click on cron-tab.
- Now there are two options Standard and Advance(Unix Style).
- Click on the Standard – Now select minutes to “0” , Hours to every hour, month, days , weekdays to every option.
- And in the command to run text box enter “lynx -source http://your-domain/your-file.php > /dev/null“. As you can see the command called lynx which is a browsing program in Unix/Linux system and call the specified php file in every hour.
- To setup Advance(Unix Style), just click on that button and place 0 on minute and * on the hour, day , month and weekday and in the command just place “lynx -source http://your-domain/your-file.php > /dev/null“. The “*” means that every i.e. “*” in hour means that every hour, the same in day means that every day etc.
In the other control panel like Plesk have different environment where you can enter the the following command directly
0 * * * * lynx -source http://your-domain/your-file.php > /dev/null
Where 0 represents every 0th minute, the next “*” means every hour, the next “*” means every day, the next represent every month and the last one represent every weekday.