Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to list locked file in unix? Post 302275109 by methyl on Friday 9th of January 2009 09:41:35 AM
Old 01-09-2009
man fuser
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How can a file be locked for a certain time?

I want to be able to lock a file for 60 minutes so that an automated monitoring program will not execute the script more that once an hour. I have never used a lock file but have heard that is what I need to use. Does anyone have any examples of how I would use this? lock 60 filename.ksh ---?... (6 Replies)
Discussion started by: darthur
6 Replies

2. UNIX for Dummies Questions & Answers

list of active and locked OS accounts

Hello all I'm trying to generate a list of active and locked accounts at the end of every month...How would I know which account is active and which is locked or diabled ...I was looking at the /etc/passwd file but I was not sure how to differentiate between an active account and a locked... (4 Replies)
Discussion started by: luft
4 Replies

3. Shell Programming and Scripting

checking whether a file is locked

hi Guys, I just wondering how I can check and ensure a file is not locked by another process. I need to modify a file using sed but I need to ensure that is not being modified by another process at the same time. Thanks. Harby. (2 Replies)
Discussion started by: hariza
2 Replies

4. UNIX for Dummies Questions & Answers

find locked files, print file path, unlock file

using OS X and the Terminal, I'd like to find all locked files in a specified directory, unlock them, and print a list of those files that were unlocked how can I do this? I'm familiar with chflags nouchg for unlocking one file but not familiar with unix enough to do what I'd like. Thanks! (0 Replies)
Discussion started by: alternapop
0 Replies

5. HP-UX

how to list locked users in hp-ux?

Actually.I have 2 questions to ask. 1. how to list locked account in hp-ux? 2.how to list locked account in linux(redhat)? I can use the command "passwd -S -username" to list a account who were locked . who knows how to list all locked accounts with one command. Thanks!! (5 Replies)
Discussion started by: robbiezr
5 Replies

6. UNIX for Dummies Questions & Answers

How do i list all locked account in linux?

Hi How do i list all locked account in my linux distributiion I have tried passwd -S -a but it seems to not working . My distribution details. # lsb_release -a LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch Distributor ID: OracleVMserver... (3 Replies)
Discussion started by: pinga123
3 Replies

7. Shell Programming and Scripting

Check if file is locked otherwise gzip it

Dear community, I've a continuos tcpdump on redhat that close the dumped file every 100000 captured packets. To avoid disk full I would like to gzip the closed *.cap file. But how can I check if the file is currently opened by tcpdump and skip it from gzip? Thanks! EDIT: Just to post an... (9 Replies)
Discussion started by: Lord Spectre
9 Replies

8. UNIX for Dummies Questions & Answers

UNIX Account getting Locked Everyday between same Time Frame

I am facing an Issue with a particular Unix Account ( ie a particular Userid) getting LOCKED everyday between 7:30am and 8:00am. The Password associated with this particular Account has been setup such that it should never Expire at all but it does LOCK the Account after more than 3 failed... (5 Replies)
Discussion started by: pchegoor
5 Replies

9. Shell Programming and Scripting

How to kill the process when the file is locked?

I was trying to read the file to create a table in SAS and I got error as follows while I read. Resource is write-locked by another user. File =/usr/sas/sas_config/Lev1/SASApp/StoredProcessServ​er/Logs/SASApp_STPServer_2015-09-29_tmp_18208.log. System Error Code = 0. ERROR: File is in... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies

10. Shell Programming and Scripting

How to check the file locked or in use at FTP?

Hi Experts, I am beginner to shell scripting, I have a archive script which will connect to the FTP server and archive the files from FTP source location to FTP archive location. Now the problem here is, the script working for few files and not working for few.I am facing the below error... (1 Reply)
Discussion started by: spidy
1 Replies
fuser(2)							System Calls Manual							  fuser(2)

NAME
fuser - Reports PIDs and UIDs for files, file systems and/or the devices attached to them. SYNOPSIS
#include <sys/fuser.h> int fuser( char *file, long flag, struct f_user fuser_array[], long sizeof_fuser_array ); PARAMETERS
Specifies the file name. Specifies one of the following values. If none of the following are values are specified, the default is to match open files. Matches only file ids. Provides mount point matching. Matches deleted files on the mount point specified by file. Specifies the array. Specifies the number of elements in the fuser array. DESCRIPTION
The fuser function reports a list of PIDs and UIDs that are associated with a specified file, file system, and/or the devices that are attached to them. The fuser function can report back additional information about "matches" by ORing one of the following constants that can be passed back in the member fu_flags: Current directory Current directory Parent of the current directory At least one file open, but the number open is not known. Executable image. Controlling terminal Trace At least one file is mmapped RETURN VALUES
On success, the fuser function returns the number of fuser_array elements that were found. The contents of the structure are as follows: typedef struct f_user { pid_t fu_pid; int fu_flags; uid_t fu_uid; } f_user_t; If an error has occurred, the fuser function returns -1 and sets errno to indicate the error. ERRORS
If the fuser function fails, errno may be set to one of the following values: The array is not large enough to hold the number of array elements returned or the array structure cannot be filled The file parameter specified does not exist EXAMPLES
Open regular files and special files are matched using the flag parameter set at 0L. Thus, if process 127 and 3220 open the /home/try file simultaneously and the fuser function is active, the PIDs and UIDs associated with the home/try file are reported as in the following exam- ple: fuser("/home/try", 0L, fuser_array, (long) (sizeof (fuser_array)/sizeof(fuser_array[0])); Similarly, if the special device file /dev/ttyp2 is open by process 32, then that PID and its associated UID are reported as in the following example: fuser("/dev/ttyp2", 0L, fuser_array, (long) (sizeof (fuser_array)/sizeof(fuser_array[0])); fuser(2)
All times are GMT -4. The time now is 07:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy