Implementing scheduled task:HOW TO?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
highjo
Forum Contributor
Posts: 118
Joined: Tue Oct 24, 2006 1:07 pm

Implementing scheduled task:HOW TO?

Post by highjo »

Hi! there.i'm trying to write a function that runs after a regular periode.For example the function should pull data like new suscribed clients from my database every 6 PM.the fact is i don't have idea about how to implement it.can anyone give me an idea?
I'm on windows and running XAMPP 1.6.5 thanks
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Implementing scheduled task:HOW TO?

Post by aceconcepts »

It sounds like a cron job would be the most fitting solution for this.

Take a look at http://www.sitepoint.com/article/introducing-cron

Do you use cPanel? If so, cron jobs are very simple to setup from here.

Hope this helps :D
User avatar
highjo
Forum Contributor
Posts: 118
Joined: Tue Oct 24, 2006 1:07 pm

Re: Implementing scheduled task:HOW TO?

Post by highjo »

Ok! have the understanding.One more question.Since the cron job is done by Linux OS ,that means i can't try it with my XAMPP package locally.Most of the time we develop on windows and deploy on linux isn't there anything else to test and see its behaviour in terms of testing?thanks
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Implementing scheduled task:HOW TO?

Post by aceconcepts »

I'm not entirely sure about local testing - sorry :(
User avatar
highjo
Forum Contributor
Posts: 118
Joined: Tue Oct 24, 2006 1:07 pm

Re: Implementing scheduled task:HOW TO?

Post by highjo »

hello! i'm thinking about a new scenario where the task is limited a number of time.for example i'm sending a sms from the web sites and the actual sending is done through a http request.I'll need to check if the sms is delivered to the handset by another http request which i'm sending with the curl library let's say every 5 seconde and 5 times only.am i still in the case of linux cron job? can this be done in php ?and is there a better option to achieve this?please let me know.thanks
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Re: Implementing scheduled task:HOW TO?

Post by benyboi »

I use a windows server and have a load of "cron jobs"/scheduled tasks running... what i do is use the built in "sceduled taks" thing in windows.

Just make a new task to run:

Code: Select all

C:\PHP5\php.exe -f D:\files\do.php
Where "C:\PHP5\php.exe" is the location of your php.exe file and "D:\files\do.php" is the file you want to run!

Hope that helps...
User avatar
highjo
Forum Contributor
Posts: 118
Joined: Tue Oct 24, 2006 1:07 pm

Re: Implementing scheduled task:HOW TO?

Post by highjo »

thanks dude!i'll try that
Post Reply