The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perform action file name written to the pipe fed.linuxgossip Shell Programming and Scripting 2 07-23-2008 11:38 AM
written a srcipt with 2 arguments sam4now Shell Programming and Scripting 6 04-29-2008 06:06 AM
check written data Hitori Linux 0 07-22-2006 09:46 AM
Checking a file is not being written to kanejm Shell Programming and Scripting 14 01-20-2006 08:29 AM
Operating on a file being written by another application GMMike UNIX for Dummies Questions & Answers 3 02-01-2005 04:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-12-2001
sanjay92
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Question File being used/written

Hello,
Which command in unix can tell whether a file is being used/written by another process.

e.g. If one process is copying a very big file in some directory and there is another cronjob process which checks for a new file and in this directory and process the file. I want to check, if the file is still being written by the last process.

Sanjay
  #2 (permalink)  
Old 10-12-2001
sanjay92
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Code:
#!/bin/ksh

x=`cksum File_Name.exp | awk '{print $1}'`
#sleep 1
y=`cksum File_Name | awk '{print $1}'`
if [  $x = $y ] ; then
  echo "Both are same" $x $y
else
  echo "Both are different" $x $y
fi
This method will work to find out, if the file is still being written by comparing the two snapshots of checksum of file.

Is there any other good method ?

Thanks for taking your time.

Sanjay

added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 04:11 PM..
  #3 (permalink)  
Old 10-12-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
If you have lsof you can use that to see
what files are open. You can use...
lsof -F File_Name.exp
...and use that output. I would suggest reading
the man page carefully though. There are alot
of "note" and options.

All said and done though your solution appears
to be simple and if it works...I say stick
with it.
  #4 (permalink)  
Old 10-13-2001
sanjay92
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Thanks for reply.
Unfortunately, I did not find isof utility/command in my unix system. I have SunOS 5.6 Generic_105181-23 sun4u sparc SUNW,Ultra-Enterprise.
Is this utility has to be installed seprately or may be not in my path listing and also I did not find man isof as well.

Sanjay
  #5 (permalink)  
Old 10-13-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
Yes. It normally isn't installed (until revently).
You'll have to go get it, build it and install
it.

Go to this link...
http://www.cert.org/security-improve...s/i042.05.html

...it's the best reference for me...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0