I am creating a cronjob in cPanel that runs a simple PHP script.
If my CronJob fails then the server automatically sends me an email which is good, but how can I trigger this error from my PHP script?
Is there a way like with exit() or similar?
I am creating a cronjob in cPanel that runs a simple PHP script.
If my CronJob fails then the server automatically sends me an email which is good, but how can I trigger this error from my PHP script?
Is there a way like with exit() or similar?
2
Answers
Explicitly
exit
from the program and pass a valid exit status that is not 0 so that cron will recognise it as exiting in an error state.I don’t have tested yet but there is a function on php for trigger custom error.
Take a look there –> https://www.w3schools.com/php/func_error_trigger_error.asp