I have a PHP script that run on cron every 5 minutes.
*/5 * * * * /var/www/html/processMail.php
Inside the script there is a function that I want to execute every 15 minutes, so that function will be in sleep mode but the rest of the script will be process every 5 minutes.
does this crazy idea will work and how?
No it won’t. The each 15 minute function would – even if you manage to wait 15 minutes – be executed each 5 minutes – so effectively the 15 minutes function is executed each 5 minutes. Instead create a second script that is executed every 15 minutes or add a parameter:
Then use the functionality to parse commandline-parameters in PHP (and
getopt) to process accordingly. See as well the section about commandline usage in the PHP manual.