Problems with user environments when run cron
Hi,
I have a user Oracle in the Server Suse 10, the user environments put in .profile. The User Oracle have few cron but and this cron execute scripts RMAN backup. The output about cron is Subject: Cron <oracle@db10gserver> sh /u01/backup/scripts/testeo.sh 2>&1 >> /u01/backup/scripts/logs/testeo_rman.log X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/home/oracle> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=oracle> X-Cron-Env: <USER=oracle> Message-Id: <20081021181701.37CF21684D6@db10gserver.uoct.cl> Date: Tue, 21 Oct 2008 15:17:01 -0300 (CLST) ': not a valid identifiero.sh: line 1: export: ` Message file RMAN<lang>.msb not found Verify that ORACLE_HOME is set properly The environment is in the script but The Cron take another environment. i thinks the problem is the environment about user Oracle, When one cron is executed, what bash is executed similar a .profile when one user logon on server ? Regards, Walter The cron line 10 0 * * 1,3,5 /backup/scripts/incremental_backup_rman.sh 2>&1 >> /backup/scripts/logs/incremental_backup_rman.log The Script RMAN #!/bin/sh export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1 export ORACLE_SID=censo export PATH=$ORACLE_HOME/bin:$PATH rman target=/ << EOF RUN { backup incremental level 1 cumulative tag '%TAG_Level1' database; backup tag '%TAG_ARCHIVELOG' archivelog all not backed up delete all input; } EXIT; EOF S.O Suse 10. Regards, Walter |
Moin,
cron does not execute the user's profiles and has an environment different to a login shell. First you should not start a shell script using "sh /path/to/script", you should explicitely specify the shell to use: "/bin/bash /path/to/script" and you should define the complete environment you need within the script (you can source the user's profiles: ". /home/oracle/.bashrc" for example). Jan |
Quote:
I agree he needs to add or source the correct env inside the shell script. |
Moin,
Quote:
Another point: Even if you define the shell at the shebang line - if you call the script using sh /path/to/script, the calling shell executes the script and doesn't take care of the shebang line: Code:
jan@jack:~/tmp> cat bash.sh Jan |
All times are GMT -5. The time now is 08:09 PM. |