08-31-2007
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 tempfind.txt
cat tempfind.txt | \
while read line
do
echo "**$line**"
fuser -uV $line >> tempmail.txt
echo "::"
cat tempmail.txt
echo "::"
done
#cat tempmail.txt | mailx -s "$Subject" $MAIL_RECIPIENTS
In the above script, command fuser is not wroking properly, means for some of the files its showing the process no with user name, but for some its not showing. I am getting output like: (here i have made some check points that print the present value of the tempmail.txt, tempfind.txt and $line)
/clocal/mqbrkrs/user/mqsiadm/sanjay $ AccessMonitor_Script
/clocal/mqbrkrs/user/mqsiadm/sanjay/tempfind.txt
/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor_Script
/clocal/mqbrkrs/user/mqsiadm/sanjay/tempmail.txt
**/clocal/mqbrkrs/user/mqsiadm/sanjay/tempfind.txt**
/clocal/mqbrkrs/user/mqsiadm/sanjay/tempfind.txt:
::
::
**/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor_Script**
/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor_Script:
inode fd=62 (mqsiadm)
::
1015990::
**/clocal/mqbrkrs/user/mqsiadm/sanjay/tempmail.txt**
/clocal/mqbrkrs/user/mqsiadm/sanjay/tempmail.txt:
::
1015990::
/clocal/mqbrkrs/user/mqsiadm/sanjay $
Any Idea on this ???
Please reply ASAP!!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
2. AIX
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
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
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
5. UNIX for Dummies Questions & Answers
Hi,
I have a problem I don't understand with fuser.
I launch a simple shell script mysleep.sh:
I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted:
mysleep:
Then I modify my script switching from #!/bin/sh to #!/bin/ksh
I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies
6. Shell Programming and Scripting
Hi,
I am writing a bash script (running on Centos 5.4) to process video (.MTS) files which may have appeared in a certain directory. The files will be dragged and dropped there from a Windows box using Samba, and the script is to check periodically (i.e. run from cron) whether any new .MTS... (0 Replies)
Discussion started by: Palamedes
0 Replies
7. Solaris
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
8. UNIX for Dummies Questions & Answers
if filename.txt is in used, exit, else continue.
i tried to use fuser -c filename.txt, but returned bunch out PIDs eventhough filename.txt is not in used.
any idea ? (10 Replies)
Discussion started by: tjmannonline
10 Replies
9. UNIX for Advanced & Expert Users
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
10. Shell Programming and Scripting
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
LEARN ABOUT SUNOS
pathconv
pathconv(1F) FMLI Commands pathconv(1F)
NAME
pathconv - search FMLI criteria for filename
SYNOPSIS
pathconv [-f] [-v alias]
pathconv [-t] [-l] [-nnum] [-v string]
DESCRIPTION
The pathconv function converts an alias to its pathname. By default, it takes the alias as a string from the standard input.
OPTIONS
-f If -f is specified, the full path will be returned (this is the default).
-t If -t is specified, pathconv will truncate a pathname specified in string in a format suitable for display as a frame title. This
format is a shortened version of the full pathname, created by deleting components of the path from the middle of the string until
it is under DISPLAYW -- 6 characters in length, and then inserting ellipses ( ... ) between the remaining pieces. Ellipses are
also used to show truncation at the ends of the strings if necessary, unless the -l option is given.
-l If -l is specified, < and > will be used instead of ellipses ( ... ) to indicate truncation at the ends of the string generated by
the -t option. Using -l allows display of the longest possible string while still notifying users it has been truncated.
-nnum If -n is specified, num is the maximum length of the string (in characters) generated by the -t option. The argument num can be
any integer from 1 to 255.
-valias |string If the -v option is used, then alias or string can be specified when pathconv is called. The argument alias must be an
alias defined in the alias_file named when fmli was invoked. The argument string can only be used with the -t option and must be a
pathname.
EXAMPLES
Example 1: A sample that uses pathconv to construct the menu title. It searches for MYPATH in the alias_file named when fmli command.
Here is a menu descriptor that uses pathconv to construct the menu title. It searches for MYPATH in the alias_file named when fmli was
invoked:
menu=`pathconv -v MYPATH/ls`
.
.
.
where there is a line in alias_file that defines MYPATH. For example, MYPATH=$HOME/bin:/usr/bin.
Here is a menu descriptor that takes alias from the standard input.
menu=`echo MYPATH/ls | pathconv`
.
.
.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
fmli(1), attributes(5)
SunOS 5.10 5 Jul 1990 pathconv(1F)