coldbackup file errors syntax issue need help
Here is my script and here is the error can anyone lend a hand?
coldbackupits.sh # cron script to shutdown database backup files and startup database #!bin/sh echo "SHUTTING DOWN THE DATABASE AND BACKING UP THE FILES COLD " # connect to sqlplus and shutdown database and backup database files cd /mnt/backups/scripts sqlplus -s "/ as sysdba" << EOF shutdown immediate; cd /mnt/apps2/oracle/ITS tar -cvzf inst.tar.gz inst cp -R inst.tar.gz /mnt/backups/ITS cd /mnt/backups/scripts sqlplus -s "/ as sysdba" << EOF startup; OUTPUT SHUTTING DOWN THE DATABASE AND BACKING UP THE FILES COLD Database closed. Database dismounted. ORACLE instance shut down. tar: inst: Cannot stat: No such file or directory tar: Error exit delayed from previous errors SP2-0734: unknown command beginning "sqlplus -s..." - rest of line ignored. ORACLE instance started. Total System Global Area 1068937216 bytes Fixed Size 2233336 bytes Variable Size 427822088 bytes Database Buffers 624951296 bytes Redo Buffers 13930496 bytes Database mounted. Database opened. |
Your first line should have a slash in front of bin:
#!/bin/sh You should verify /bin/sh is the one you want - on many systems it is a symbolic link to another shell (e.g. bash or dash) and sometimes shells (e.g. dash) don't do things the way you think they do in other shells. Most of your errors stem from the common problem in cron and other background jobs: That is that the environment variables are not set the same way they are when you run from a login session. Cron has a very minimal environment. The main variable you need is PATH as that tells it where to find commands. If you notice in your output it says it can't find various commands. You can set variables in the script for example: export PATH=/oracle/bin:/bin:/usr/bin:/onlygodknows/bin:$PATH Alternatively you can put the full path of commands in the script for example: /bin/tar -cvzf inst.tar.gz inst -NOT JUST- tar -cvzf inst.tar.gz inst There may be other variables you need to set. For example if it were Oracle you'd need to set things like ORACLE_HOME so that the sql commands you ran knew the Oracle environment. |
Everything MensaWater said; also add
Code:
set -xv Code:
<cron time setting> /dir/coldbackupits.sh >/dir/coldbackupits.log 2>&1 |
All times are GMT -5. The time now is 05:45 PM. |