LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   executing a time-triggered script (https://www.linuxquestions.org/questions/programming-9/executing-a-time-triggered-script-188055/)

leosuth 05-31-2004 12:14 PM

executing a time-triggered script
 
I have a customer whose website is hosted on a Linx machine running Apache, generated from a MySQL database using PHP ASP. My requirement is:

Users fill info into a form, which when submitted is loaded by PHP into a table in the MySQL database. OK so far. What I need is a way of notifying the customer that there is new info in the table (info from possibly several users)

What I envisage is a process running o the Linux machine that every 15 minutes, say, kicks a PHP script into action. This PHP script would then query the MySQL database to look for new information, and then, if new info is found, send an email to the customer to notify them.

How can this be done? Can Apache be setup to kick a PHP script at regular intervals? Please help, I'm fairly new at PHP and Linux.
:rolleyes:

david_ross 05-31-2004 01:51 PM

Welcome to LQ.

Take a look at the crontab man page. It will show you how to create scheduled tasks.

leosuth 06-01-2004 03:49 AM

Ta.

Unfortunately, I haen't got a Linux or UNIX machine - so no crontab.

I am aware of cron and crontab - that was how I was going to kick my process off. What I wanted to know is if it is possible to kick a PHP script just by putting 'script.php' into the appropriate place in the cron table?

Kp2Sushi 06-01-2004 04:10 AM

In perl I'd do this
 
If you have a perl installation installed you can do this:
Code:

#!/path-to-perl/perl -w

$sleep_interval = 15 * 60

for(;;)
{
    sleep $sleep_interval;
    `command ;
}

There ya go, your very own scheduled executor.

itsme86 06-01-2004 05:57 AM

The command would be: php script.php

david_ross 06-01-2004 02:12 PM

Re: executing a time-triggered script
 
Quote:

Originally posted by leosuth
I have a customer whose website is hosted on a Linx machine running Apache, generated from a MySQL database using PHP ASP.
Quote:

Originally posted by leosuth
Unfortunately, I haen't got a Linux or UNIX machine - so no crontab.
So do you or do you not use a linux box? Does this have anything to do with linux or is it just an open source question?

leosuth 06-01-2004 03:10 PM

I don't, but my customer does - and since I am not too familiar with Linux, this is where I came for help. Speaking of which, thanks to everyone for their help - question answered.

deiussum 06-02-2004 08:15 AM

Put the crontab entry on the customer's computer.


All times are GMT -5. The time now is 05:15 PM.