0

Hi Guys,
I have a question about PHP and Ajax/Javascript SetInterval.

Im working on an application that users will be able to subscribe to and I want
an email sent to them after !exactly 24 hrs. The only way that I could think of doing
something like this is by creating an interval that will execute an Ajax function that will call a php function that compares the user subscription timestamp to the current timestamp and if it's greater than 24 hrs it will send the email.

The application is working fine, but I just realized that when the browser is closed,
the SetInterval functions stop working?! I thought that after executing it once it will keep working on the server but I was wrong... I tried to create a simple application that uses php/ajax and logs the current timestamp every 3 seconds into a txt file, again it's working fine but only when the browser page that have the script on is open!

Is there a way to create an interval that keeps working on the server without anyone viewing the page that calls the function ?

Thanks

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by vibhaJ
0

You need cronjob dear.
In cronjob you can set php file name and time interval that will execute that php file.
e.g. you have sendnewsletter.php and set time 'every night 12am'.
Server will call that file daily at 12am, thats it.. all is done.

Cronjob setting is in server's hosting panel.
See this link http://www.siteground.com/tutorials/cpanel/cron_jobs.htm for guidance.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.