Answer the question
In order to leave comments, you need to log in
How to run Cron task more than a minute?
Hello. Tell me how to run a php script in CronTab more than once a minute?
Video is the solution:
Run the task every 30 seconds:*/1 * * * * root /home/mybin/script.sh; /bin/sleep 30; /home/mybin/script.sh
Run the task every 20 seconds:*/1 * * * * root /home/mybin/script.sh; /bin/sleep 20; /home/mybin/script.sh; /bin/sleep 20; /home/mybin/script.sh
Run the task every 15 seconds:*/1 * * * * root /home/mybin/script.sh; /bin/sleep 15; /home/mybin/script.sh; /bin/sleep 15; /home/mybin/script.sh; /bin/sleep 15; /home/mybin/script.sh
Answer the question
In order to leave comments, you need to log in
Stopudovo is some kind of stupid task that doesn’t require a cron at all, these “secrets” are boring, write normally - “I can’t figure out how to do % certain_functional% correctly, I got the idea to do it wrong, how to do it right?”. No, everyone writes - "my skis do not go on asphalt, tell me how to attach wheels and a rocket engine to them, for which I will not say, this is the Great Secret."
It's easier to run one script that runs "always" in a loop, and there you can already set a delay in seconds in it, if necessary.
Why not just run a long-running task that will check the time and perform the required action at the right moments?
Explain how long this common task takes to complete? Is it always guaranteed to be within 15 seconds? If there is a risk of overlapping adjacent executions due to the first one taking too long, you will need somewhere to store the time of the previous run and the “running right now” / “free” status flag.
Here is a solution, just for Beget - https://www.pandoge.com/stati_i_sovety/zapusk-zada...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question