LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 10-11-2013, 12:07 PM   #1
abhilashsriram
LQ Newbie
 
Registered: Oct 2013
Posts: 2

Rep: Reputation: Disabled
Shell script to copy the logs from production to DR


Hello,
I am trying to write a shell script to copy the archivelogs from production server to the DR server but i am not able to make it. I am attaching the code what i have tried please send me your answers.



#!/bin/bash
df -h |grep /var > mount_space
cat mount_space | awk '{print $4}' > free_space
if [ $b >= 1G ]
then
ls -lrth /home/prod/dr > lst_dr
tail -1 lst_dr | awk '{print $9}' > last_dr
ls -lrth /home/prod/prod > lst_prod
tail -1 lst_prod | awk '{print $9}' > last_prod
for ((i=last_dr;i<=lat_prod;i++))
do
cp /home/prod/prod/*.Z /home/prod/dr/
done
else
echo 'insufficient space to copy'
fi



Thanks,
Abhilash sriram
 
Old 10-11-2013, 01:02 PM   #2
rm2629
LQ Newbie
 
Registered: May 2013
Location: USA
Distribution: Android, Mint, Ubuntu
Posts: 12

Rep: Reputation: 4
For starters, the test $b is invalid, you have not created, nor assigned a variable 'b'.

Try the following:

Code:
b=`cat mount_space | awk '{print $4}'`
Also, after your first line, add a line:

Code:
set -xv
When you re-run your script, it will print out some debug with those flags enabled. Post if there are further problems.
 
1 members found this post helpful.
Old 10-25-2013, 11:10 AM   #3
abhilashsriram
LQ Newbie
 
Registered: Oct 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Shell script

Hi i have tried your code but its not working i am posting the information please go through the script and do the need full and also i am posting the output of the code. By setting the "set -xv" line after the first line the entire program is shown in the output once again i dont need that. Please go through the information.

[oracle@dbalab6 abhi]$ sh shell.sh
df -h |grep /var > mount_space
+ df -h
+ grep /var
b=`cat mount_space | awk '{print $4}'`
cat mount_space | awk '{print $4}'
++ cat mount_space
++ awk '{print $4}'
+ b=1.7G
if [ $b >= 1G ]
then
ls -lrth /home/prod/dr > lst_dr
tail -1 lst_dr | awk '{print $9}' > last_dr
ls -lrth /home/prod/prod > lst_prod
tail -1 lst_prod | awk '{print $9}' > last_prod
for ((i=last_dr;i<=lat_prod;i++))
do
cp /home/prod/prod/*.Z /home/prod/dr/
done
else
echo 'insufficient space to copy'
fi
+ '[' 1.7G 1G ']'
shell.sh: line 5: [: 1.7G: unary operator expected
+ echo 'insufficient space to copy'
insufficient space to copy

--> I do have checked the mount point space but its fine even though it is throwing the error.

--> I do have one more idea for this can we use rsync command to copy the logs but the problem in using this command is crosschecking of the archives is not happening.

Last edited by abhilashsriram; 10-25-2013 at 11:13 AM. Reason: correction
 
  


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
Writing a shell script for logs movement to remote location. Satyaveer Arya Programming 12 04-08-2013 08:05 PM
[SOLVED] script as shell for non-production user in /etc/passwd drManhattan Linux - Server 4 12-28-2011 07:08 AM
[SOLVED] Shell Script or Command to Remove PDF file from large logs Doknik Linux - Newbie 2 07-14-2011 09:39 AM
shell script to copy files eduard Linux - Newbie 9 07-13-2011 04:26 PM
Shell Script for keeping track when guest user logs on system... computergeek7 Programming 1 04-01-2010 03:10 PM


All times are GMT -5. The time now is 04:39 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