![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
Quote:
And the file can be removed during the sort. The file will continue to exist without a name. |
|
#5
|
|||
|
|||
|
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
|
||||
|
||||
|
Quote:
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
|
||||
|
||||
|
Perhaps try: sort -o x x
|
||||
| Google The UNIX and Linux Forums |
| Tags |
| solaris |
| Thread Tools | |
| Display Modes | |
|
|