The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bourne Shell: if elsif question leostar_10 Shell Programming and Scripting 3 03-09-2008 07:37 PM
IF THEN ELIF question in BOURNE SHELL arun_st UNIX for Dummies Questions & Answers 4 04-20-2007 12:41 PM
Bourne-again shell mrsamer UNIX for Dummies Questions & Answers 3 09-30-2006 02:42 AM
cd from a Bourne Shell Script - Please Help fawqati Shell Programming and Scripting 10 05-25-2006 03:26 AM
Bourne Shell and Arrays Unbeliever Shell Programming and Scripting 2 07-25-2005 10:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-28-2004
gillbates gillbates is offline
Registered User
  
 

Join Date: Mar 2002
Location: DC
Posts: 46
bourne shell timing question

In one of my scripts I do the following

sort +0 x > y
mv y x

In my script x and y are fully qualified. This works 99% of the time. However once in a while the system comes back and says that is cannot access y in the mv command.

I did some research and I suspect that if I insert a "wait" command inbetween these two lines it will work. Although the wait command is for background processes. Is that what's happening here? Is the sort with a redirect happening in the background?

Thanks, Gill

OS = Solaris
  #2 (permalink)  
Old 01-28-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
wait can not help. I suspect something external to the script. sort can take a while to run. Plenty of time for someone else to do "rm y".
  #3 (permalink)  
Old 01-29-2004
gillbates gillbates is offline
Registered User
  
 

Join Date: Mar 2002
Location: DC
Posts: 46
Sabotage? y is actually /xxxx/xxxxxx/xxxxxx/xxxx/nnnnnnnn.xxx.$$ in length. Would someone be able to delete it while the redirection was happening? While quite a few people happen to know this userid/pswd I find this fairly hard to believe. I'll test that scenario though.
  #4 (permalink)  
Old 01-29-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Quote:
Originally posted by gillbates
Sabotage? y is actually /xxxx/xxxxxx/xxxxxx/xxxx/nnnnnnnn.xxx.$$ in length. Would someone be able to delete it while the redirection was happening? While quite a few people happen to know this userid/pswd I find this fairly hard to believe. I'll test that scenario though.
Rather than sabotage, how about a bug? Most of us encounter bugs every week. Maybe it's finally happened to you too.

And the file can be removed during the sort. The file will continue to exist without a name.
  #5 (permalink)  
Old 01-29-2004
gillbates gillbates is offline
Registered User
  
 

Join Date: Mar 2002
Location: DC
Posts: 46
I'm very good at producing bugs myself. But this code has run as is for years. The server was moved last weekend but I don't think there were any os changes. By the way, the sabotage line came from a user (ex submariner) that decided his bugs had to be sabotage. But considering that these files contain the processes pid to ensure they don't get overwritten by another instance of the process it would have to be someone jerking my chain if they were getting removed. We have a high priced unix consultant here that told me that sort with the redirection causes a seperate process to occur and the redirection is asyncronous so he thought that the move was happening before the redirection flushed the buffers. He suggested that I could add a sleep 1 or rm x before the move and probably never have the problem again. Gill
  #6 (permalink)  
Old 01-29-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Quote:
Originally posted by gillbates
We have a high priced unix consultant here that told me that sort with the redirection causes a seperate process to occur and the redirection is asyncronous so he thought that the move was happening before the redirection flushed the buffers. He suggested that I could add a sleep 1 or rm x before the move and probably never have the problem again. Gill
Redirection as you have done does not cause an extra process.

Redirection is not asyncronous with other elements of your script.

Redirection does not cause any buffers to be flushed.

If anything is in the buffer cache and not yet synced to disk, that is irrelevant. All i/o goes though the buffer cache anyway.

"rm x" to make y spring back into existence? Whoa.... I don't even know what to say about that.

"sleep 1" increases the window between the creation of the file and the time the mv needs it. This is likely to make the problem occur with greater frequency.
  #7 (permalink)  
Old 01-30-2004
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
Perhaps try: sort -o x x
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0