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.
For the sake of clarity I would add that any command or custom executable script can be set to run at certain time with precision up to 1 min.
Few cents from me, You can add 2>&1 also to redirect the errors/warnings also to the empty file (/dev/null) Code (text): 0 * * * * "your_command_to_run" > /dev/null 2>&1
Cron is a time-based job scheduler in Unix-like computer operating systems. The name cron comes from the word chronograph (a time-piece). Cron enables users to schedule jobs (commands or shell scripts) to run automatically at a certain time or date. ...