Sponsored Content
Operating Systems Solaris Before I delete any file in Unix, How can I check no open file handle is pointing to that file? Post 302459805 by kchinnam on Tuesday 5th of October 2010 11:48:23 AM
Old 10-05-2010
Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command.

I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file.

Is there another command that can tell if a file has a truely active open file handle pointing to it ? or if a file has a runtime PID associated with it?
 

10 More Discussions You Might Find Interesting

1. Solaris

Error Message: find: cannot open /: Stale NFS file handle

I am using the "find" command below and it respond with the error message " find: cannot open /: Stale NFS file handle" what does it mean? what can I do about it? Need advice, thanks. below are the command that I enter, the respond and the error message: root@ScripServer:/# find / -name... (1 Reply)
Discussion started by: ezsurf
1 Replies

2. UNIX for Dummies Questions & Answers

delete open file

hi, I have a little problem. I deleted a file, which was opened in vim editor. it was bad idea... now "df" still display same space. I kill process vim, but maybe file was controlled or opened by another application. Is any eventuallity to find which process has lock file? Command "ps -ax"... (2 Replies)
Discussion started by: delonism
2 Replies

3. UNIX for Advanced & Expert Users

Unable to delete an open file

I am working on a unix server. I killed all the processes with my id on the machine. After that I tried to delete a file, I got an error:- file not removed.Text File busy. Deletion of directory prompted:- Directory not empty. Can anyone help me regarding this...??? Thanks, Vikas (11 Replies)
Discussion started by: vikasrout
11 Replies

4. Shell Programming and Scripting

avoid open file to check field.

Hi Everyone, # cat a.txt 94,aqqc,62345907, 5,aeec,77, # cat 1.pl #!/usr/bin/perl use strict; use warnings; use Date::Manip; open(my $FA, "/root/a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\,/, $_); if (index($tmp, "qq") ne -1) { ... (4 Replies)
Discussion started by: jimmy_y
4 Replies

5. Shell Programming and Scripting

how to open a file and read a file in UNIX

HI can any one tell me how to open and read a file in UNIX actually i have the following script can you please suggest me on this.. LOG,">$log" or NotifyAdmin "Failed to open file $log";... this is the perl statement.. which opens log file. i want to open same log file in unix Thanks... (5 Replies)
Discussion started by: sravan008
5 Replies

6. Shell Programming and Scripting

Need unix commands to delete records from one file if the same record present in another file...

Need unix commands to delete records from one file if the same record present in another file... just like join ... if the record present in both files.. delete from first file or delete the particular record and write the unmatched records to new file.. tried with grep and while... (6 Replies)
Discussion started by: msathees
6 Replies

7. Shell Programming and Scripting

Check file presence and delete other file

Hello, I have file all_file.txt at the end of process this file all_file.txt should be deleted only if there is no file present in dir /all_file/tmp/ or in it's sub directory. can you please help me with the peace of code for this. Thanks (2 Replies)
Discussion started by: kumar30213
2 Replies

8. UNIX for Dummies Questions & Answers

UNIX command to check if file name ends with .tar OR if the file is a tar file

Hello Team, Would you please help me with a UNIX command that would check if file is a tar file. if we dont have that , can you help me with UNIX command that would check if file ends with .tar Thanks in advance. (10 Replies)
Discussion started by: sanjaydubey2006
10 Replies

9. Shell Programming and Scripting

To check if a file is open and in use (logs are being written to it)

Hello Experts, I need to write a shell script to check if a file is open and something is being written to it. I want to know how OS handles it. I checked with lsof command but it is not working. For a test I did this. while true; do echo `date` >>abc.txt; done then I checked lsof |... (5 Replies)
Discussion started by: shekhar_4_u
5 Replies

10. UNIX for Beginners Questions & Answers

How to check if a file is open in editor?

Hi there! I'm developing a program that allows the user to open and edit files using both an editor and the terminal. Once the user has finished editing the file an update is sent to the logbook that compares the file before and after it was edited - this can only be done if the file is closed (I... (23 Replies)
Discussion started by: cherryTango
23 Replies
checkrestart(1) 						  debian-goodies						   checkrestart(1)

NAME
checkrestart - check which processes need to be restarted after an upgrade SYNOPSIS
checkrestart [ -hvpa ] [ -b blacklist_file ] [ -i package_name ] DESCRIPTION
The checkrestart program tries to determine if there are processes in the system that need to be restarted after a system upgrade. This is necessary since an upgrade will usually bring new system libraries and running processes will be still using the old versions of the libraries. In stable Debian GNU/Linux systems this is typically needed to eliminate a system exposure to a vulnerability which might have been fixed by upgrading a library which that process makes use of. Consequently, checkrestart is sometimes used as an audit tool to find outdated versions of libraries in use, particularly after security upgrades. Administrators should not, however, rely on its output completely (see BUGS below). This script needs to run as root in order to obtain the information it needs for analysis. OPTIONS
-h,--help Show the program help and exit. -v,--verbose Generate detailed output. This output includes the list of all processes found using deleted files or descriptors as well as the deleted files and descriptors found. -p,--package Only process deleted files that belong to a package, ignoring deleted files which do not have an associated package in the package system. -a,--all Process all deleted files regardless of location. This makes the program analyse deleted files even if they would be discarded because they are located in locations, such as /tmp , which are known to produce false positives. It will take preceded if used simultaneously with the -p option. -b file,--blacklist=file Read a blacklist of regular expressions from file. Any files matching the patterns will be ignored. -i name,--ignore=name Ignore services that are associated to the package name provided in name. EXIT STATUS
The program will exit with error (1) if a non-root user tries to run it. Otherwise, it will always exit with error status 0. BUGS
This program might fail if the output of the lsof utility changes since it depends on it to detect which deleted files are used by pro- cesses. It might also output some false positives depending on the processes' behaviour since it does not check yet if the (deleted) files in use are really libraries. If you find a false positive in checkrestart please provide the following information when submitting a bug report: -- The output of checkrestart using the -v (verbose) option. -- The output of running the following command as root: lsof | egrep 'delete|DEL|path inode' Checkrestart is also sensitive to the kernel version in use. And might fail to work with newer (or older) versions. A rewrite to make it less dependent on lsof could improve this, however. SEE ALSO
lsof(8) AUTHOR
checkrestart was written by Matt Zimmerman for the Debian GNU/Linux distribution. COPYRIGHT AND LICENCE
Copyright (C) 2001 Matt Zimmerman <mdz@debian.org> Copyright (C) 2007,2010-2011 Javier Fernandez-Sanguino <jfs@debian.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. On Debian systems, a copy of the GNU General Public License may be found in /usr/share/common-licenses/GPL. debian-goodies December 19 2006 checkrestart(1)
All times are GMT -4. The time now is 02:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy