motasem13hamad Posted August 5, 2014 Share Posted August 5, 2014 Hi peps,I am trying to write a script that allows for events to be executed at any given time that user gives it like if the user wants it at 2 am the event will execute at that given time i read some answer they say use cron but im using windows how to do it ?? Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/ Share on other sites More sharing options...
Solution Barand Posted August 5, 2014 Solution Share Posted August 5, 2014 WIndows has a Task Scheduler http://msdn.microsoft.com/en-gb/library/windows/desktop/aa383614%28v=vs.85%29.aspx Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1486858 Share on other sites More sharing options...
motasem13hamad Posted August 6, 2014 Author Share Posted August 6, 2014 i mean that the user should select time of execution its like the user want to send a message but he should choose the sending time ? until now i cant find anything to do that dynamically Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1486968 Share on other sites More sharing options...
Jacques1 Posted August 6, 2014 Share Posted August 6, 2014 Barand just told you how to do it. You set up a script which is regularly executed by the operating system, checks if there are any messages to be sent, and if that's the case, it sends them. Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1486972 Share on other sites More sharing options...
motasem13hamad Posted August 10, 2014 Author Share Posted August 10, 2014 //is there an api for php ?? cause i cant find something related to it ? Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1487321 Share on other sites More sharing options...
Jacques1 Posted August 10, 2014 Share Posted August 10, 2014 API for what? I have no idea what you're talking about. Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1487322 Share on other sites More sharing options...
motasem13hamad Posted August 10, 2014 Author Share Posted August 10, 2014 i want to run a php script at anytime that user wantlike there is an sms the user want to sent okaybut he have to choose when to send it i dont know when it gonna happen Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1487323 Share on other sites More sharing options...
Jacques1 Posted August 10, 2014 Share Posted August 10, 2014 What is wrong with you? We've already told you how to do it. We've explained the exact steps. Yet you keep repeating the same sentences like a madman. Did you see our replies? Did you understand them? If not, then ask, but don't just skip the answers and repeat your question. That doesn't get you anywhere. Yes, I understand that you want to run a PHP script at user-defined points of time. I'm not stupid. To implement this, you tell the Windows Task Scheduler to run a certain PHP script every minute (or whatever time interval you find appropriate). This script checks if there are any user-defined actions to do at this point in time and executes them. Let's say user A wants to send an SMS at 16:00 today (UTC), and user B wants to send an SMS at 18:30. Your server would do this: ... 11:11: call PHP script -> nothing to do 11:12: call PHP script -> nothing to do 11:13: call PHP script -> nothing to do ... 15:59: call PHP script -> nothing to do 16:00: call PHP script -> user A wants to send an SMS, do it ... 18:29: call PHP script -> nothing to do 18:30: call PHP script -> user B wants to send an SMS, do it ... You get the idea? Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1487324 Share on other sites More sharing options...
CroNiX Posted August 10, 2014 Share Posted August 10, 2014 (edited) A bit harsh, Jacques. You'd set up a single task in the windows task scheduler that runs every 5 minutes or so (I think 1 minute would be a bit much, but you can if you want). That executes a php script. There are lots of examples in google how to set this up. When the php script is executed, it checks a database to see if there are any sms to send out for the last 5 minutes (or whatever you want). If there are any present, send the sms's. You would create some form or something for your users to set a time to send a sms, along with the message, and that's what gets stored in the above mentioned database. As far as API to be able to directly manage tasks in the windows task scheduler, you could probably do that using a COM extension, but that would be much more difficult than the above. It would just be a lot easier to just have 1 task that executes your php script every x minutes. Edited August 10, 2014 by CroNiX Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1487338 Share on other sites More sharing options...
motasem13hamad Posted August 11, 2014 Author Share Posted August 11, 2014 its just my first time using scheduler thats all i saw the link thats Barand post put i didn know how to make it work so i thought that you did not understand my problem and thanks for helping me , sorry for bothering Quote Link to comment https://forums.phpfreaks.com/topic/290277-time-based-events-in-php/#findComment-1487388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.