perform some function based on time
Moderator: General Moderators
perform some function based on time
it is possible to do a function automatically based on time.
for example.
perform the action of the function called myfun on 12:00 AM everyday.
is it possible?
for example.
perform the action of the function called myfun on 12:00 AM everyday.
is it possible?
absolutely. You could run php in application mode... You'll have to search that up.
Or
You could run a shell script at the shell level if yur rocking some variant of linux/unix. uhh, yeah you'll have to search that up too.
Or perhaps you could have a javascript clock written into an html document use the SetTimeOut() function that automatically loads myfun.php at a given time which could have myfun() inside it.
Or
You could run a shell script at the shell level if yur rocking some variant of linux/unix. uhh, yeah you'll have to search that up too.
Or perhaps you could have a javascript clock written into an html document use the SetTimeOut() function that automatically loads myfun.php at a given time which could have myfun() inside it.
my idea is that in myfun() these will perform.
1. access the records from mysql
2. produce a report
3. send the report to the admin by email
4. the procedures must be at 12:00 pm
so, i think these may require something that is different from ur answer. may b ur right. if so, plz tell me the way (code or link)
1. access the records from mysql
2. produce a report
3. send the report to the admin by email
4. the procedures must be at 12:00 pm
so, i think these may require something that is different from ur answer. may b ur right. if so, plz tell me the way (code or link)
wh33t wrote:absolutely. You could run php in application mode... You'll have to search that up.
Or
You could run a shell script at the shell level if yur rocking some variant of linux/unix. uhh, yeah you'll have to search that up too.
Or perhaps you could have a javascript clock written into an html document use the SetTimeOut() function that automatically loads myfun.php at a given time which could have myfun() inside it.
Well I'm not too sure about application mode, but I'm pretty sure what it does is allow a php script to run like an object oriented language like C... but very minimally. Probably a bit of over kill for what you need.
Oh I know what you could do...
Just have a Scheduled Event in windows, that loads up webbrowser that runs yur php script at noon. Thats probably the easiest.
Oh I know what you could do...
Just have a Scheduled Event in windows, that loads up webbrowser that runs yur php script at noon. Thats probably the easiest.
plz put some code or some links to prove ur word
wh33t wrote:Well I'm not too sure about application mode, but I'm pretty sure what it does is allow a php script to run like an object oriented language like C... but very minimally. Probably a bit of over kill for what you need.
Oh I know what you could do...
Just have a Scheduled Event in windows, that loads up webbrowser that runs yur php script at noon. Thats probably the easiest.
Ummm I cant really do that seeing how a WINDOWS SCHEDULED EVENT is created from the control Panel in windows.
Basically what I'm saying is go to http://www.yourwebsite.com/myfun.php <-- create a shortcut to the on your desktop.
Set up your Scheduled Event in windows to run that short cut at the time you desire.
But I do have a question. Do you often come in here for help and expect people to write you whole scripts to solve your problem? And do they actually do that? Cause that would be new to me.
Basically what I'm saying is go to http://www.yourwebsite.com/myfun.php <-- create a shortcut to the on your desktop.
Set up your Scheduled Event in windows to run that short cut at the time you desire.
But I do have a question. Do you often come in here for help and expect people to write you whole scripts to solve your problem? And do they actually do that? Cause that would be new to me.
sorry .. i misunderstand my words. my need is do on the web server!
wh33t wrote:Ummm I cant really do that seeing how a WINDOWS SCHEDULED EVENT is created from the control Panel in windows.
Basically what I'm saying is go to http://www.yourwebsite.com/myfun.php <-- create a shortcut to the on your desktop.
Set up your Scheduled Event in windows to run that short cut at the time you desire.
But I do have a question. Do you often come in here for help and expect people to write you whole scripts to solve your problem? And do they actually do that? Cause that would be new to me.
You will probably have to use a shell script then. Assuming your webserver is a linux or unix machine. You'll have to head over to a different forum probably as this doesn't have a whole lot to do with programming. But there still might be an easier way to do this.
Consider heading over to:
http://linuxquestions.org/ and going into their forums. Its a great community, go there and ask about shell scripts or cron jobs and they might have some better suggestions. Sorry I dont have any code for you.
Consider heading over to:
http://linuxquestions.org/ and going into their forums. Its a great community, go there and ask about shell scripts or cron jobs and they might have some better suggestions. Sorry I dont have any code for you.
Use a cronjob service such as http://www.cronjob.de
Or...
If you don't need it to be done _exactly_ at 12, you can just check if the last time (saved in a text file) the function was run was >24 hours ago. If so, run it.
Or...
If you don't need it to be done _exactly_ at 12, you can just check if the last time (saved in a text file) the function was run was >24 hours ago. If so, run it.