As a hacker, I have to program my remote web server to automatically perform routine tasks for me. It's a whole lot easier and cheaper to rely on my web hosting company to manage an always-on server. For starters, I don't have to pay for the 24/7 electricity the on-call technician!
To make the server perform an automated task in a Linux or Unix environment, you need to schedule a cron job. I won't go through all the details of setting it up in shell terminal since most people do not have remote shell access. You can read about the details more at the cron and crontab Wikipedia articles. Most of us deal with an interface on the cPanel that looks kind of like one of these two screens.
Do I Run the PHP Text File or a Program?
There are three ways you can do this. The first way is to actually call the PHP interpreter binary to run the PHP script. The second way is to call a text-based browser for terminal environments. The last way is to call an HTTP retriever. To see which one works for you, create a PHP file that emails your Inbox when it is successfully executed.
mail ("email@example.com", "Cron Successful!", "Hello World!");
This will only work if your server parses PHP files as a CGI directive. That is, PHP is not installed as an Apache module. Most newer web server setups utilize PHP via the Apache module since it is a more secure setup. Therefore, this may not apply to you. If you want to test it out, cron the above PHP script with this:
If referring to the PHP interpreter does not work, you will need to call a text web browser to open the file, thus forcing the HTTP daemon to run the script. There are many text browsers out there. The most popular one is Lynx. It should be included on most *nix environments.
Apparently, my web host removed the lynx command so I was forced to look elsewhere. My last resort was HTTP retrievers like "get" and "wget." Basically, these binaries "get" the file from the HTTP daemon like text browsers and usually save it somewhere.
Good luck! If you have any question or suggestions, please leave a comment!