Step by Step Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Step by Step Script
# 8  
Old 11-18-2003
The fact is that I need to be sure the tape really finished writing before issue the next command.

Maybe there is a way to check if the tar process is still working, although it has already gave control back to the OS.

Can anybody tell me how to identify if a process is still working?

Iīve tied with the cp ick1 ick9 || cp ick88 ick99 || cp ick3 success example but coud not undertand exactly what it does.

Itīs the first time I work with UNIX and itīs hard to get used to all the possibilities that pipes and redirection and filters opens.

Thanks for your patience

Lisandro
# 9  
Old 11-18-2003
One of the best man pages you can read is for the shell itself (ksh, sh etc.). From ksh:

The symbol && (||) causes the list following it to be executed only if the preceding pipeline returns 0 (or a non-zero) value.

Cheers,

Keith
# 10  
Old 11-18-2003
Quote:
Can anybody tell me how to identify if a process is still working?
You can do this by polling the process with the ps command. If you were to put the tar command in the background then you could capture its PID. Then sit and wait for it to complete by checking to see if that PID is still running.

see man ps
# 11  
Old 11-18-2003
To detect errors, you can also do a "set -e" which will cause the shell to exit if any command returns a non zero status.

Detecting that a command failed is different from detecting that a command launched a background process before returning. It would not be easy to detect that. If a command started a separate process, it would often be to run some other command. So that "ps" would not be very general.

I have never seen a version of tar that would behave that way. The final close of the tape device may involve a rewind operation. The close system call should not return to tar until the rewind is complete. If that is not happening, the tape driver has a bug. I can't imagine any other circumstances where this might even be possible.

In general, commands return after they are finished. Any exceptions to this should be noted in the docs for the command. I really only encounter this behavior when I expect to. For instance, a command like "start-web-server" or something would reasonably be expected to leave a running web server. But the resulting process would most likely be called "httpd".
# 12  
Old 11-18-2003
Thanks Perderabo, kduffin and google.

Thatīs the behaviour of the tar command that I should expect, but my boss insists in saying that it uses buffers and gives back control to the OS before the actual writing finishes.

Iīll try to build something using the process number and wait until itīs not running, just to please him :-(

Thanks
# 13  
Old 11-18-2003
Quote:
Originally posted by lisafern
but my boss insists in saying that it uses buffers and gives back control to the OS before the actual writing finishes.
That is probably true. But it depends on the exact command, the exact filesystem(s), and the exact os version, and possibly on the exact hardware. It also depends on his definition of "buffer".

In the case of a tar to tape, the data will be on tape before the command exits. In case of copy disk to disk, it's complicated. Unix tries to do read-ahead and write-behind with most disk i/o to a file in a filesystem. Usually disk reads and writes go to and from a buffer cache. Some file systems now have special options to control this, (vxfio on HP-UX) but that is kinda new. A syncer program runs every so often (30 seconds on HP-UX) to flush out old data. There is a sync program that can flush the data as well. But sync and syncer only schedule the i/o... some time may be needed for the driver to process the request.

Today's disk drives are really little computers and they too have a cache. They can have a feature called immediate-report which makes them pretend that a write is finished when it has just been cached locally in the drive. A well designed drive can even withstand (in theory) a powerfail in this state. When power is restored, the drive will write the data. The OS may be able to control this behavior (scsictl in HP-UX).

One universal way to be sure that all data has been flushed from the system to the drives: unmount the filesystem. The unmount will not succeed until after the data is flushed. Well, this bummed people out when applied to nfs filesystems and some OS's now discard(!) the data on a nfs dismount if the nfs server is not responding. (Nothing is sacred anymore...)

My company is also very paranoid about losing data. We replicate our data to three massive servers... 2 in North America and one in Europe.
# 14  
Old 11-18-2003
Perderabo:

Thanks for your support.

The script its suposed to copy files to a tape device using tar. Itīs a script for one of our customers, using a SUN Ultra 10 server with Solaris 8 as OS.

As far as I knew, the disks have internal buffers, but tape devices not.

I had the chance to get some more info about the problem and the situation is this one:

The problem is (as far as I know) that the script first copies files from the current machine to the tape device and when finishes calls other server to backup some files using the same device, but the second server gets an error message stating that the device is still in use.

If you imagine something I can use to be sure that the device is free, please let me know.

(actually the script is issuing an "at" command 15 minutes ahead in order to let the tape device finish working, but they donīt like this approach).

thanks !!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

Slowly Removing Bold Font Style - Step-by-Step

FYI, I'm slowly removing a lot of the bold font-styles from titles of discussions, forum titles, etc I'm not removing bold for the entire site because we do need bold from time to time, especially in posts and sometimes in other places. However, the original forum style had way too much... (3 Replies)
Discussion started by: Neo
3 Replies

2. UNIX for Advanced & Expert Users

Test shell script step by step?

Hi to all, I don't know if someone has done sometime a MS Excel Macro, that allows us to press F8 over the code to see step by step, to mention something, how is running the code, which values take the variables, if some loop is executing correct or where a error occurs, and some other... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

3. Linux

May you explain step by step where and how I will add pseudo code

Thank all of you. May you explain step by step where and how I will add pseudo code Note : I have Linux 2.6.24-26-server on x86_64 dears kindly help me (3 Replies)
Discussion started by: nonowa
3 Replies

4. Solaris

Step by step to replace Failed disk

Hi all. This may be a stupid question but here goes: I lost a disk on my Sun-Fire 480-r and want to replace it. I don't care about the data, I just need to get a new disk in. Can anyone supply me with step by step procedure please. I am not an expert by any means and it is a dev box so I... (1 Reply)
Discussion started by: jamie_collins
1 Replies

5. UNIX for Dummies Questions & Answers

looking for step by step emacs c++ debug tutorial

Hello all i was searching the net for simple but effective tutorial to show me how debug c++ in emacs with not much luck. im not new to unix but new to emacs , i looking for tutorial that shows how to debug ( if possible ) c++ programs . LIike IDE suppose to , break points step in/out variable... (0 Replies)
Discussion started by: umen
0 Replies

6. Shell Programming and Scripting

works step by step on command line but not in script

Hi all, The following script is fine when I work via command line m=1 c=0 while do echo $m gnokii --getsms IN $m > out.txt; m=`expr $m + 1`; cat out.txt >> message_log; ############ read first crap< <(sed -n '/Text:/{n;p;}' out.txt); read message< <(sed -n '/Text:/{n;p;}'... (2 Replies)
Discussion started by: whamchaxed
2 Replies

7. UNIX for Dummies Questions & Answers

Step by step Installation of Unix SCO 2.1

I am new to unix and server at my job crashed due to hardware problem. I'm now opted to install sco unix on a new server - could anybody help me with the steps I need to take (pretty old machine) Thanks & Regards Nancy :( (0 Replies)
Discussion started by: nensee7
0 Replies
Login or Register to Ask a Question