menu

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/import2dolibarr.sh >> /dolibarr/automation/logs/unitedhwimport.log

which is calling this bash script (import2dolibarr.sh):

#!/bin/bash
currentDate=`date`
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/statements.pvmercantile.com/html/sync-ops/united-hardware/uh-inv-sync.php
/usr/bin/php /var/www/statements.pvmercantile.com/html/sync-ops/united-hardware/uh-inv-stock-add.php

When the import2dolibarr.sh 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.

Suggestions?

Comments:
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.