LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-21-2012, 03:46 PM   #1
wdsmith45
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Rep: Reputation: Disabled
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.
 
Old 02-21-2012, 04:35 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,578
Blog Entries: 14

Rep: Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969
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.
 
Old 02-21-2012, 07:24 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Everything MensaWater said; also add
Code:
set -xv
at the top after the "#!/bin/sh" line and capture the output
Code:
<cron time setting> /dir/coldbackupits.sh >/dir/coldbackupits.log 2>&1
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash Arithmetic Syntax Errors MTK358 Programming 23 08-15-2011 12:04 PM
[SOLVED] Slack 13.1, HTTPD syntax errors & missing lib mdlynn Slackware 4 08-26-2010 12:15 AM
couple C++ syntax errors bru Programming 8 05-16-2004 06:35 PM
Gimp-1.2.3 'make' reports syntax errors GabeF Linux - Software 2 06-11-2003 09:29 PM
declaration syntax errors with KYLIX rklosinski Programming 1 11-28-2002 02:49 PM


All times are GMT -5. The time now is 12:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration