Run the script on command after a certain time?

There is a script that resets your product user, if not paid after a certain time, just need it to automate, that is, until he runs so that it just checks the time, if the user executes any command in the bot, it's not right. Kron is not suitable, since you want the script after a certain command, waited a while, then worked. The loop and sleep are not suitable, as the processor is loaded on 100%, are there any outputs?
April 3rd 20 at 17:34
3 answers
April 3rd 20 at 17:36
Write the time in the database and Kron run every minute.
Kron looks at the order time to 12:00 if the current time is 12:10 and there is no payment then removes the reservation (which you need if the time is unknown but let's say 10 min wait). If Kron ran the file as (current time) - (time of order) < 10 it does nothing.
That was probably the solution, thanks. Only bad thing is that he will do this constantly,as it is incorrect, and yet may be delayed for 59 seconds. Another solution no one has ever suggested, so I think that is the best - Dustin87 commented on April 3rd 20 at 17:39
@Dustin87, it is Actually strange that the cycle slip and so loaded processor. For the first time can make an error of a minute yet to find a better way. Ie tell the user that are waiting for payment 5 minutes but in some cases he will have a chance to pay 59 seconds longer. I think it's not scary for the first time - Doug.Koss commented on April 3rd 20 at 17:42
@Doug.Koss, me too it seemed strange, but the hosting administrators complain - Dustin87 commented on April 3rd 20 at 17:45
Can be done using supervisord to keep the script in memory and always hanging, and in scripte do sleep like 10 sec, then max delay will be 10 sec - Garland commented on April 3rd 20 at 17:48
@Garlandcan be - Dustin87 commented on April 3rd 20 at 17:51
April 3rd 20 at 17:38
The loop and sleep are not suitable, as the processor is loaded on 100%

Something was done wrong apparently.

In General, for such is the task schedulers such as CRON.
Cron just does not fit, because cron runs continuously after a while. I need it to only run on the team and practiced after a certain time. And for sleep and I don't see where there can be a mistake. Performed the command, then worked need a script where there was sleep, after sleep had run their course, he checked the database for payment of goods - Dustin87 commented on April 3rd 20 at 17:41
@Dustin87which team? - roel_Kerluke commented on April 3rd 20 at 17:44
For example a bot, choose goods, he is booked, at this time the script runs, once the user has booked the item. So I stopil executing the script with the sleep command, so he did a check on the database until the time of the reservation - Dustin87 commented on April 3rd 20 at 17:47
@Dustin87, really get into the thoughts and sformuliruet fine idea, you're doing something strange. - roel_Kerluke commented on April 3rd 20 at 17:50
What's strange? How can I still validate? Every 6 minutes via cron? This is nonsense, because the user can book the product, and crowns work before, and the check will take 6 minutes for example, and 4 minutes as the Kron worked already 2 minutes ago - Dustin87 commented on April 3rd 20 at 17:53
@Dustin87when the user has booked the item, add this item to a list of items to check and add. In the crown of a working script that runs every minute/30 seconds/15/how-anyone within the margin of error and checks the list: if it's time, makes a check and deletes the entry from the list, if not, then does nothing. - Brent.Berge commented on April 3rd 20 at 17:56
@Dustin87, step by step:
I'm doing this, that would be like this, then that is something.
Does your bot a booking request that you and your party to do?

As long as my guesses, we can conclude that you need a queue. - roel_Kerluke commented on April 3rd 20 at 17:59
5df1480aba425706800366.jpeg5df1481535cac119565076.jpeg

Selected item, after it barrueta. I have to check the time to pay that in 6 minutes the product was removed from the armor - Dustin87 commented on April 3rd 20 at 18:02
@Dustin87, you need a queue and a daemon that will turn to rake.
Came a booking request - threw in turn, and pointed out that it is necessary to perform after such a time.
The demon is constantly hanging and rake this line. Worker in General.

To store place only not in MySQL, some take a Radish or Memcache - roel_Kerluke commented on April 3rd 20 at 18:05
April 3rd 20 at 17:40
What hinders to make so:
Man wrote the bot made a reservation.
I write in PHP echo 'ok' (or whatever it is for the correct answer) and prescribe - fastcgi_finish_request();, then write code:
sleep(600); //600 seconds / 60 = 10 minutes (waiting time)
// * here the code to check, the payment was made or not *

Less solutions that the process will hang in the 10 minutes + of run time and returns the answer (with proper code optimization is 1-3 seconds max), but load it does not create because he simply would sleep all these 10 minutes.

Find more questions by tags PHPTelegram