Question:
How to automate repetitive task in PHP?
erwin150
2008-08-17 20:42:13 UTC
Hi, i am building a game using PHP. The game server needs to be run every minute. What i do now, is using cron job to run the server every minute. Another alternative, I am thinking of using loop, but the drawback is, it cannot be stopped whenever i want. Is there a better way to do this other than using CRON JOB and LOOP command? Is there a PHP command that can be time-triggered? Help please. Thanks in advance.
Three answers:
Stuart D
2008-08-19 23:55:18 UTC
When developing a PHP script you have to becareful of the memory usage. If you leave a script running over and over and over forever it would eventually consume so much memory it would become a burden (unless you wrote flawless code)



Nevertheless you would need to run this somewhere



My advice to you is that as you want it to run every minute use a crontab as this will be sufficient enough for you and work perfectly



if you need to run every second then run a crontab, use a for loop of 0 < 59 then insert the sleep(1); function so that it pauses inbetween.



As I say crontab will work best for you here.
anonymous
2016-10-23 08:37:02 UTC
Create a macro on your attitude application. Then keep that macro and upload it on your Scheduled initiatives to set the time for it to run. which will be got here across by technique of clicking commence, classes, upload-ons, gadget equipment, scheduled initiatives. the way you're making the macro relies upon on which application you're utilising. case in factor: in Excel, click equipment, then Macro then record macro and do precisely what you want to do, interior the ORDER that you want it carried out. Then provide up the recording. positioned it aside. feels like I kept you $215 an hour ;)
anonymous
2014-12-01 01:30:19 UTC
difficult issue. research using yahoo. it could actually help!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...