Questions & Answers

Cron does not work, but manual commands do...?

On a standard Debian 10 server, configured for LAMP, I have a crontab entry:

0 3 * * 1 /bin/bash /dolibarr/automation/united-import-scripts/ >> /dolibarr/automation/logs/unitedhwimport.log

which is calling this bash script (

echo $currentDate
mv -v /dolibarr/automation/united-import-scripts/files/*.inv /dolibarr/automation/united-import-scripts/files-hold/
mv -v /dolibarr/automation/uhftpdown/*.inv /dolibarr/automation/united-import-scripts/files/
/usr/bin/php /dolibarr/automation/united-import-scripts/import_inv.php
mv -v /dolibarr/automation/united-import-scripts/files/*.inv /dolibarr/automation/united-import-scripts/files-processed/
/usr/bin/php /var/www/
/usr/bin/php /var/www/

When the script runs via the crontab entry, all of the mv commands work as expected, but none of the .php scripts run at all.

On the other hand, when I use the exact same command lines as in the shell script in the CLI, they run just as one would expect.

The generated log file shows no errors, nor do any of the logs I checked.

The crontab is executing under the root user.


2023-01-17 00:46:09
Check for permissions/environment issues - cron will be a different user and environment.
2023-01-17 00:46:09
Answers(1) :

Wow! Ouch! Turns out that I forgot to set a +x on the php scripts. Seems to be working now.