Handle error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Handle error
# 1  
Old 01-08-2013
Handle error

I have a script as below , the script can tar file to the tape , however , it is fail to handle the error , if there is error like the backup file is in writing , then it will echo this is fail ( but the file has successful backup actually , so the backup task is succes , but it still report it is fail ) , can advise how to modify it so that if all files are backup , then echo this is success ? thanks

Code:
tar -zcvf /dev/st0 ...
if [ $? -eq 0 ] ;
	then echo this is success
else 
 echo this is fail

fi


Last edited by Scott; 01-08-2013 at 12:41 PM.. Reason: Code tags
# 2  
Old 01-08-2013
So there's an error in the backup file, but you don't care about it, because it's not inside files you care about...?

I still think that's a cause for concern.

Better to fix the error than try to selectively ignore them. You'll end up ignoring errors you shouldn't and land in real trouble.
# 3  
Old 01-08-2013
So there's an error in the backup file, but you don't care about it, because it's not inside files you care about...? ==> I think the output messages is only for alert , as the backup is complete , I think it can be ignore.

I still think that's a cause for concern.

Better to fix the error than try to selectively ignore them. You'll end up ignoring errors you shouldn't and land in real trouble.

==> the error is not easy to fix , as the files is always writing ( this is system log file ) , therefore , the "message" is presist. is there any better way to modify the script , so that it can ignore such messages , can kindly advise the backup script ?

thanks.
# 4  
Old 01-09-2013
You can instruct tar to not try and archive that file with -X, which reads a list of filenames to ignore.

Code:
echo filename-to-ignore > /tmp/exclude-list

tar -X /tmp/exclude-list ...

rm -f /tmp/exclude-list

# 5  
Old 01-09-2013
Quote:
Originally Posted by ust
==> the error is not easy to fix , as the files is always writing ( this is system log file ) , therefore , the "message" is presist. is there any better way to modify the script , so that it can ignore such messages , can kindly advise the backup script ?
thanks.
Dude, you've been posting on Linux forums since 2003....and youv'e asked this question before. don't you understand what folks tell you?
# 6  
Old 01-11-2013
Quote:
Originally Posted by Corona688
You can instruct tar to not try and archive that file with -X, which reads a list of filenames to ignore.

Code:
echo filename-to-ignore > /tmp/exclude-list

tar -X /tmp/exclude-list ...

rm -f /tmp/exclude-list

-X seems will exclude to backup the file , if I just want to backup the file but exclude the error only , is it ok ?

thanks
# 7  
Old 01-11-2013
It's warning you about backing up a file that's being written to because that's really a no-no. You really need to cooperate with whatever's creating the logfile here. Can you stop the service while the backup is happening, or at least lock the file temporarily?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

NFS write error on host xyz: Stale NFS file handle - Solaris 10

Oct 13 12:19:15 xyz nfs: NFS write error on host xyz: Stale NFS file handle. Oct 13 12:19:15 xyz nfs: (file handle: 68000000 1bc5492e 20000000 377c5e 1ce9395c 720a6203 40000000 bdfb0400) Oct 13 12:19:15 xyz nfs: NFS write error on host zyz: Stale NFS file handle. Oct 13 12:19:15 xyz nfs: ... (5 Replies)
Discussion started by: psychocandy
5 Replies

2. UNIX for Dummies Questions & Answers

Difference between handle to the thread HANDLE and thread identifier pthread_t

This question might be silly but its confusing me a bit: What is the difference between handle to the thread HANDLE and thread identifier pthread_t? ---------- Post updated at 01:52 PM ---------- Previous update was at 01:48 PM ---------- Sorry I saw details and HANDLE is in windows and... (0 Replies)
Discussion started by: rupeshkp728
0 Replies

3. Shell Programming and Scripting

How to handle one value below the other

Hi, I, have an output with 3 different values each below the other like: # echo $bla 123 345 234 Each value is in one line and for the further processing I need every single value. For example is there a way to grep line 2, like: # echo $bla | grep --line 2 345 :) Thank you in... (6 Replies)
Discussion started by: 2retti
6 Replies

4. Shell Programming and Scripting

handle decimals

Hi All, How we can handle decimals in (Float) in UNIX. a=73 b=5 c=`expr a / b` i am getting 14 but i need full 14.6 . Can any one help me pls? (1 Reply)
Discussion started by: subin_bala
1 Replies

5. Solaris

NFS write error on host : Stale NFS file handle

:confused:Hi all When i see in the /var/adm/messages, i saw the following error unix: NFS write error on host : Stale NFS file handle. unix: (file handle: 45ca415 3e7 a0000 2c7f6 3ebfc25f a0000 2 3e49) It is using sunOS 5.7. Is anybody know what is this error? Is is related to any network... (2 Replies)
Discussion started by: AirWalker83
2 Replies

6. Solaris

Error Message: find: cannot open /: Stale NFS file handle

I am using the "find" command below and it respond with the error message " find: cannot open /: Stale NFS file handle" what does it mean? what can I do about it? Need advice, thanks. below are the command that I enter, the respond and the error message: root@ScripServer:/# find / -name... (1 Reply)
Discussion started by: ezsurf
1 Replies

7. UNIX for Advanced & Expert Users

How to handle my own mail

I installed sendmail and pine and I could send emails to other people succesffly. However no matter what I try I cannot receive other people's email. The only messages sitting in my pine inbox are system notifications sent to root@knoppix. Then I think the problem is that my mail is handled by... (3 Replies)
Discussion started by: onthetopo
3 Replies

8. Shell Programming and Scripting

FTP - To handle error while transferring files

Hi, I had written an FTP script where in I loop through the directories and transfer the files from each and every directory of Windows to UNIX. Now the problem is when 1. The connection is unable to be established I should return some error codes 2. When there is some system... (1 Reply)
Discussion started by: mahalakshmi
1 Replies

9. Programming

How to handle memory error?

Hi, I need to know what is the right way of handling out of memory conditions. If a program is not able to dynamically allocate memory (new fails), is it right to wait for some amount of time (say 5 sec) and then try again to allocate memory? Or should we kill the process and again restart it?... (1 Reply)
Discussion started by: diganta
1 Replies

10. Programming

handle core

Hi I am looking for analog of the Windows "try-except" C code statement that enables target applications to gain control when events that normally terminate program execution occur. (1 Reply)
Discussion started by: vlad
1 Replies
Login or Register to Ask a Question