Tutorial :Server process with PHP+MySQL


I am new to web programming, and I am developing a simple appointment app with PHP + MySQL. Is there a simple way to add a background process on a timer (to send out daily appointment reminders, for example)? This could be done easily in another language, but I want it to run on shared hosting with only PHP.


Your host may or may not approve of this. You can write a PHP script for use on the command line and make a crontab entry to run it periodically. If you don't have command-line access to the PHP interpreter, you could write the script to run in the web server and hit it with wget or curl, also using a crontab entry.


If you have a Linux webhost, you might be able to use a cronjob (to automatically run a script periodically)--even on shared hosting. Some webhosts with shared web hosting allow you to create cronjobs via cPanel (or whatever they use).

That would really be your best bet, as opposed to creating a background process on the server, which the webhost probably would not be very kind about. So definitely check and see if you can use cron.


I work in a place where I cannot set a cron job so I made a page that when viewed it checks the time since the last time it did a list of jobs. If the time since job last run is over a set threshold it runs the list of jobs. Then I set up a scheduled job on a computer that I know is on all the time and connected to the internet and would open the page every 10 minutes. Worked pretty constantly. Got the idea from Joel on a stack overflow podcast episode.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »