fuser


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers fuser
# 8  
Old 02-21-2011
I'd accept one decade, but not two decades.
As usual jlliagre there are so many versions of unix that you have not used that you get an impression of standardisation - but only within your own experience.
# 9  
Old 02-21-2011
Getting back to our thread orginator's query:-
Quote:
Originally Posted by tjmannonline
fuser -f worked, but now i ran into another issue. my script:

fuser -f file1 > /tmp/active.log

if [ -s /tmp/active.log ] && [ -s /tmp/file2 ]
then
echo "exiting"
exit
else
mv /tmp/file2 /tmp/file2.timestamp
fi

since this crontab runs * * * * *, mv /tmp/file2 /tmp/file2.timestamp "A file or directory in the path name does not exist".
...I think that you have moved on from fuser into file testing logic. What you have coded says:
  1. Capture PIDs into /tmp/active.log
  2. If /tmp/active.log exists and is empty AND /tmp/file2 exists and is empty, then write a message and exit, otherwise rename /tmp/file2 to /tmp/file2.timestamp
Moving on, you are renaming /tmp/file2 to /tmp/file2.timestamp every minute too. This may cause conflict just on the bad luck of timing anyway, but what you are seeing is that you fail the condition when /tmp/file2 does not exist. You then try to continue in the else clause and rename a file that does not exist, hence the error being displayed.

If you can describe the logic you are trying to write into your code, someone may be able to help you get the various tests and flow correct.




Robin
Liverpool/Blackburn
UK
# 10  
Old 02-21-2011
Quote:
Originally Posted by methyl
I'd accept one decade, but not two decades.
fuser was definitely part of SVR4.0 released in 1989. It was formally specified in SVID 4 (1995) and later made mandatory for Unix98 systems.
Quote:
As usual jlliagre there are so many versions of unix that you have not used that you get an impression of standardisation - but only within your own experience.
I'm afraid you are confusing releases/distributions and implementations. You seem to believe every other Unix or Unix like release is a rewrite from scratch of everything. That's usually not the case, especially for basic Unix commands like fuser which are often based on SystemV source code on most commercial Unix systems released the last decade (and earlier). They can of course have extensions and cosmetic variations but they usually have very few behavior differences as introducing them would break customers scripts which is obviously something editors want to avoid. Two main branches of Unix like system that share few or no code with System V are the BSD family and Gnu based OSes, mainly Linuxes. BSDs had (originally) no fuser and Gnu/Linux has one which has the same useful split output behavior than System V. That's the reason why I was curious to know what Unix OS you were referring to when talking about discrepancy. My only guess is you were using some sort of stripped off / limited feature reimplementation like busybox.
# 11  
Old 02-22-2011
@jlliagre
I am familiar with too many versions of unix (many mainstream and many others which fell by the wayside) and until we know what Operating System the O/P has I err on the side of caution. There have been recent posts for ancient SCO unix and HP-UX 10.0 for example.

I have a large collection of useful scripts which I have ported on numerous occasions with varying degrees of success. One runs "fuser" then looks up the actual process with "ps". Not suprisingly this script has many exceptions (expecially with the "ps" bit). Judging from my comment line in 1999 an anomalous "fuser" was in Dynix though I didn't record the exact version.

I have in the distant past worked concurrenly on early SunOS (Berkeley) and unix SV R2 & R3 as well as umpeen non-unix contenders - some of which were better but more expensive.
I always treat BusyBox as an exception. Similarly Xenix and SCO (unless we know the exact version).

Anyway, I think we have cracked the original problem about extracting the PIDs from "fuser".

Last edited by methyl; 02-22-2011 at 01:14 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to get pid from fuser

bash-3.2$ fuser -f /bin/nohup.out /bin/nohup.out: 13136o 13111o The pid is 13136. Can you tell me how can i extract just the pid 13136 from the above output ? bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v I was trying on this lines but i get strange... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. UNIX for Advanced & Expert Users

Fuser alternative OR running fuser on a script

Hi, Not sure whether there is a fuser alternative or any better way to check for file in use or not. I am wanting to check whether files are in use or not before removing them. Using fuser, the awk seems to be giving me 'weird' output not to mention that it is giving me 2 lines instead of... (0 Replies)
Discussion started by: newbie_01
0 Replies

3. AIX

Fuser on VXFS not reporting processes

I have a perl script like : #! /usr/bin/perl open FILE1,">/tmp/openfile.test.out"; open FILE2,"</tmp/openfile.test.in"; open FILE3,">/data/openfile.test.out"; open FILE4,"</data/openfile.test.in"; <STDIN>; close FILE1; close FILE2; close FILE3; close FILE4; /tmp is jfs2... (0 Replies)
Discussion started by: petervg
0 Replies

4. UNIX for Dummies Questions & Answers

fuser on aix vs. linux

Pls. advise why on AIX the exit status is always '0' and on Linux it is always '1' even if the I just created a new file. I'm thinking if there is a background process monitoring the created 'file1' on AIX even if it is just a dummy or new file. How can I resolve this. (I need to justify that... (1 Reply)
Discussion started by: budz26
1 Replies

5. Solaris

FUSER problems

Greetings, I need help understanding why FUSER will not bring back PSID's on mounted filesystems. Is this a common error? Thanks in advance for your feedback. (11 Replies)
Discussion started by: Harleyrci
11 Replies

6. UNIX for Dummies Questions & Answers

fuser

Anyone ever use fuser, i tried this command fuser /database.bk but it only returns datbase.bk: I read some of the forums online, one of them said when he used fuser, it broke down the box, i really don't want that happen. I thought fuser is to see who is accessing that file, right? any... (8 Replies)
Discussion started by: adrianlearnpro
8 Replies

7. Shell Programming and Scripting

help needed in fuser command

Hi all, I want to know if fuser command can be used to check if a file is being written or not??? Thanks In Advance Anju (1 Reply)
Discussion started by: anju
1 Replies

8. UNIX for Advanced & Expert Users

fuser ?? Look at the script !!

#SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY. MYPATH="/clocal/mqbrkrs/user/mqsiadm/sanjay/" MAIL_RECIPIENTS="abc@xyz.com" Subject="File accessed in last few minutes" >tempmail.txt >tempfind.txt find "$MYPATH" -type f -amin -1 > tempfind.txt cat... (0 Replies)
Discussion started by: varungupta
0 Replies

9. AIX

fuser brought down the box

I issued fuser -k -x -u ./amqcc_r It brought down the whole box The unix admin says if I had issued fuser -k -x -u amqcc_r then it would have not brouht down the box. Does it make sense to you guys (5 Replies)
Discussion started by: bandaru
5 Replies

10. UNIX for Dummies Questions & Answers

Help with fuser

fuser is used to check whether a file is in use by a process or not. I was putting some information in a file via a background process and was doing a cat to see the contents. It gave me the pid of background process followed by stop. Understood only half, stopped because it was writing on it... (11 Replies)
Discussion started by: vibhor_agarwali
11 Replies
Login or Register to Ask a Question