Wednesday, February 20, 2013

Typical crontab mistakes for a dummy

3 things have to be born in mind when putting a service in crontab:

- crontab doesn't run .bash_profile, so you should start your script with:
source /home/soa/.bash_profile

- stderr and stdout will vanish, so always redirect both to a file:
/opt/oracle/scripts/mycommand.sh 2>&1 >> /opt/oracle/scripts/mylogfile.log

- at script start, the current directory can be anything, so to be on the safe side start with a cd /opt/oracle/scripts/



No comments: