简体   繁体   中英

Cron does not run shell script properly

im having the problem that a bash script is not running from cron. When i instead run it as root from the cli it works well. As you can see i write to a txt file when the script has finished. This is also done when the script runs from cron, only the Oracle dmp is not saved (and obviously not zipped). The job is done extremely quick, so i guess it does not do the oracle export...

Thank you for you help!

backup.sh

#!/bin/bash
#makes an Oracle  backup and zips the created file
TIME=`date +%F_%H:%M:%S`
FILENAME=Backup-$TIME

exp userid=user/password file=/home/user/DatabaseBackup/$FILENAME.dmp
zip /home/user/DatabaseBackup/$FILENAME.zip /home/user/DatabaseBackup/$FILENAME$
find /home/user/DatabaseBackup/ -mtime +0 -type f -delete

echo "Backup completed:" `date +%F_%H:%M:%S` >> /home/user/scripts/logBackup.txt
#END

crontab -e 26 * * * * /home/user/scripts/backup.sh

Ok, what i did is:

I added

>> /home/user/cron.txt 2>&1

this to my cronjob declaration, wiht this i have now the output of the cornjob.

With this it was easy to find out that some evironmet variables for oracle were missing...

Thanks for any help provided!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM