LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 02: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, 03:35 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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, 06:24 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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



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 11:04 AM
[SOLVED] Slack 13.1, HTTPD syntax errors & missing lib mdlynn Slackware 4 08-25-2010 11:15 PM
couple C++ syntax errors bru Programming 8 05-16-2004 05:35 PM
Gimp-1.2.3 'make' reports syntax errors GabeF Linux - Software 2 06-11-2003 08:29 PM
declaration syntax errors with KYLIX rklosinski Programming 1 11-28-2002 01:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:44 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
Open Source Consulting | Domain Registration