I have a cronjob calling a shell script. Inside that shell script and I have these lines:
php backup.php
(cat db-backup.sql ; uuencode db-backup.sql db-backup.sql) | mailx -s 'Database Daily Backup' mail@mail.com
rm -f db-backup.sql
When I run this shell script manually like this ./backup it creates a backup file of database, sends me an email and deletes the file. When cron calls this script It sends me a blank e-mail and it does not call/run the php file properly. What could be the cause of this problem?
Note: both shell script and php file has -rwxr-xr-x perms.
cronis probably not executing the script in a directory where your user account has write permissions. (On my system,ls -l /proc/$(pidof cron)/cwdshows the current working directory is/var/spool/cron/.)Put an explicit
cd /path/to/writable/directoryimmediately before thephpline.