How to start cron when another cron job finishes?

How to configure the cron job (cron2.php) to run after and only after the cron job (cron1.php) completes successfully?

+5
source share
2 answers

If practical, you can use shell_exec or include php in the first file to run the second file. If it is placed at the end of the first file, it will be executed only if the script successfully reaches this point, and you can use php code to verify the successful completion of the first part.

+3
source

To execute two commands, one after the other, just use ;. For example, you will see that

sleep 2; ls

, ls. crontab.

, && ( ;).

+12

All Articles