Answer the question
In order to leave comments, you need to log in
What is the best way to run a task from cron every 10 seconds?
There are a couple of solutions on the Internet how to run a task from cron every 10 seconds. (By default, it can run once a minute.) I would like to know how best to do this for my specific task and how these solutions from the Internet work (pitfalls).
I already have 5 cron jobs running every 5-10 minutes and very fast (simple quick scripts).
And I will need to run another php script every 10 seconds.
* * * * * /opt/php56/bin/php /home/k/tmp/test.php; /bin/sleep 30; /opt/php56/bin/php /home/k/tmp/test.php
* * * * * /opt/php56/bin/php /home/k/tmp/test.php; /bin/sleep 600; /opt/php56/bin/php /home/k/tmp/test.php
//Эта задача должна выполнятся каждую минуту, но sleep 600 задержит её выполнение на 10 минут.
*/1 * * * * /opt/php56/bin/php /home/k/tmp/test1.php;
Answer the question
In order to leave comments, you need to log in
Why did you decide to do a loop inside a PHP script, and not, say, something like this:
#!/bin/bash
for i in {1..10}
do
/opt/php56/bin/php /home/k/tmp/test1.php
sleep 10
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question