run a php file every 10 seconds

RicRey

Member
Feb 3, 2022
12
5
3
Ecuador
cPanel Access Level
DataCenter Provider
the temporary solution I found was to put a delay in the crons, but that means that I had to create several crons and I don't think it's the best solution... I hope someone finds something better and tells me how to implement it.


*****sleep 25 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 35 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 45 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 55 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 15 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 5 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 10 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 20 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 30 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 40 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.phpEdit Delete
*****sleep 50 && wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.php
 

quietFinn

Well-Known Member
Feb 4, 2006
1,701
352
438
Finland
cPanel Access Level
Root Administrator
for i in {1..6}; COMMAND; done
means that the COMMAND will be executed 6 times.
Also:
Since the sleep is executed only after the command is finished, the interval may be longer than 10 seconds, depending on how long the command takes. This should be taken into account.

 

RicRey

Member
Feb 3, 2022
12
5
3
Ecuador
cPanel Access Level
DataCenter Provider
for i in {1..6}; COMMAND; done
means that the COMMAND will be executed 6 times.
Also:
Since the sleep is executed only after the command is finished, the interval may be longer than 10 seconds, depending on how long the command takes. This should be taken into account.

As I understand it, if I wanted the command to be every 5 seconds it would have to be like this:

* * * * * for i in {1..12}; do /bin/wget -q -O /dev/null https://www.mydomain.com/shop/crons/cron.php & sleep 5; done