I want a script to run randomly between 30seconds to 1minute during the day between between 8am to 8pm.
Is there anything stopping me from just opening a PHP script one time with a 30-60sec sleep in a loop? And then it checks whether the time is between the 8am and 8pm?
What is the disadvantage to doing this compared to a Cron job? Can a Cron job run at random times?
The Disadvantage is, that they run forever. If it fails, you probably wont realize it instantly, and if you built it wrong, it will consume much memory and cpu without freeing it. When using cronjobs you can be sure, that it will start a clean and fresh process every time it's needed.
Additional: It's sooo damn easy to setup a cronjob, so why not?
0,30 8-18 * * * php myscript.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With