Hello,
I am calling few contents from my blog to my website, however when user goes to my website, every-time he use to come to my website the contents of the blogs are fetched and then get displayed. Which slow down the website performance.
Now i am calling my blog content to an external file which is fetching the content from my blog and storing it. And i call my content from that file to get displayed on my website.
My question is: **I want my external file (Which is storing the data in it) to automatically check for updates after every 12 hrs or say 24 hrs and save the content**, so that i don't need to manually run the script to update the content.
I am using PHP, so if you can help me doing this using PHP, it will be great. Thanks.
My approach to similar jobs is using up cron service(in Linux/UNIX, similar to Scheduled Tasks in Windows). My virtual host service provider have provided such options in its CPanel. You may also ask your service provider for assistance. cron can do jobs in intervals down to 1 minute.
To do the job, first code some scripts which I call a trigger, e.g: trigger.php, and look up in the control panel for cron jobs. For example:
(sorry for non-English pictures)
In the middle of the panel, you can set patterns for MINUTES, HOURS, DAYS, MONTHS, YEARS and enter your COMMAND scheduled to execute. * means each, so if you set MINUTES to *(with all others left to *), it means every minute cron will run your command. If you set MINUTES to 5 with all others to *, cron will run in each hour's 5th minute. Other expressions, like setting MINUTES to */10 with HOURS as 1,5,7,9 , tells cron execute command during 1st, 5th, 7th, 9th hour of the day in which interval is 10 minutes.
cron is configurable under LINUX/UNIX shells. To do this, type
An editor will show up for modifications. Configurations are same as described above. When done, save and quit.
cron service is provided with a daemon program. So remember to check that this daemon does running on your system, command top will do.