Answer the question
In order to leave comments, you need to log in
Run a script on command after a certain time?
There is a script that resets the user’s product reservation if payment has not been received after a certain time, but it needs to be automated, that is, while it works, it simply checks the time, if the user executes any command in the bot, this is not correct. Cron is not suitable, since it is necessary that the script waits for a while after a certain command, after which it works. The for and sleep loops are not suitable, since the processor is loaded at 100%, are there any solutions?
Answer the question
In order to leave comments, you need to log in
Write the time to the database and run the cron every minute.
Cron looks at the time of the order at 12:00 and if the current time is 12:10 and there is no payment, then it removes the reservation (what time you need is not known, but we assume a 10-minute wait). If the cron ran the file a (current time) - (order time) < 10 then it does nothing.
What prevents you from doing this:
A person wrote to the bot, made a reservation.
In PHP, write (or whatever is needed for a correct answer) and write - , then write the code:echo 'ok'
fastcgi_finish_request();
sleep(600); //600 секунд / 60 = 10 минут (время ожидания)
// * тут код с проверкой, была совершена оплата, или нет *
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question