The UNIX and Linux Forums  

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 04:37 PM
IF THEN ELIF question in BOURNE SHELL arun_st UNIX for Dummies Questions & Answers 4 04-20-2007 09:41 AM
Bourne-again shell mrsamer UNIX for Dummies Questions & Answers 3 09-29-2006 11:42 PM
cd from a Bourne Shell Script - Please Help fawqati Shell Programming and Scripting 10 05-25-2006 12:26 AM
Bourne Shell and Arrays Unbeliever Shell Programming and Scripting 2 07-25-2005 07:48 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 01-28-2004
Registered User
 

Join Date: Mar 2002
Location: DC
Posts: 41
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
Forum Sponsor
  #2  
Old 01-28-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,609
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  
Old 01-29-2004
Registered User
 

Join Date: Mar 2002
Location: DC
Posts: 41
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  
Old 01-29-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,609
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  
Old 01-29-2004
Registered User
 

Join Date: Mar 2002
Location: DC
Posts: 41
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  
Old 01-29-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,609
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  
Old 01-30-2004
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,248
Perhaps try: sort -o x x
Google The UNIX and Linux Forums
Closed Thread

Tags
solaris

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0