Jump to content

Time based events in PHP


flappy_warbucks

Recommended Posts

Hi peps,

 

I am trying to write a script that allows for events to be executed at any given time regardless if there is a visitor on the page or not.

 

Basically i am trying to get the website to email me reports at 16:00 everyday, and i cant actually see a way of doing this without having a visitor on the site to create an action that will start that event.

 

I have tried looking online but nothing really points to what i want, so i am asking if anyone knows of any sites that will teach me how to do this.

 

Many thanks

/- flappy -\

:)

Link to comment
https://forums.phpfreaks.com/topic/39181-time-based-events-in-php/
Share on other sites

You will need to create your php script and make it do whatever you want to do then add to cron job if you are on linux.

Cron job will execute at a time that you will specify. It basically an scheduled task that automatically executes at the specified time.

 

www.linuxhelp.net/guides/cron/

You will need to create your php script and make it do whatever you want to do then add to cron job if you are on linux.

Cron job will execute at a time that you will specify. It basically an scheduled task that automatically executes at the specified time.

 

www.linuxhelp.net/guides/cron/

 

thanks...

 

The server this will be running on is a remote windows server thats hosted by a outside company.

if you don't have access to cron then you could add some code to your index.php:

 

1. time > 4:00

2. query DB has a report been sent today?

3. send report.

4. set flag in db that report has been sent.

 

Then if your site is visited regularly the report will be sent. But obviously if no one visits your site : no report sent.

 

Better solution would be to code a simple RSS page and check that everyday (I think Firefox, IE and Outlook all cope with RSS ok). You could hide the RSS page behind an Apache user name and password to provide some security.

 

monk.e.boy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.