Score:1

Crontab - How to verify a PHP script Runs Successfully or not in a Cronjob Shell Script?

cn flag

I have below crontab in the system (Centos 7.9), However i am unable to verify if this runs correctly or not,

i.e if the crontab finds the PHP enr. variables or if the crontab has executed correctly without any errors in the shell or if the crontab entry has syntax issue ..etc

Any suggestion on how to do debug or capturing the output of a crontab like this one below

0 */1 * * * /var/www/example.com/scripts/cron.sh >> /var/log/app/cron/cron.log

Script content is like below

[root@]# cat /var/www/example.com/scripts/cron.sh
#!/usr/bin/env bash

cd /var/www/example.com/public
php cron.php 

Is there better way to do this?

Michael Hampton avatar
cz flag
I suggest that you add a crontab entry for `/usr/bin/false` and then watch what happens.
Score:1
pe flag

You can run the following

$ echo $?

If you get 0 meaning is OK, a other value over 0 is not ok.

($?) Expands to the exit status of the most recently executed foreground pipeline.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.