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
Scan Rates Negm AIX 2 04-16-2009 10:29 AM
Scan a log file nhanda Shell Programming and Scripting 3 01-19-2009 09:19 PM
Please let me know Regarding Port Scan myramkumar UNIX for Advanced & Expert Users 7 05-17-2007 11:11 AM
File Scan Dastard Shell Programming and Scripting 2 04-08-2007 03:35 PM
IP Name scan nicke30 UNIX for Dummies Questions & Answers 2 07-18-2001 05:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-07-2009
tjmannonline tjmannonline is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 91
scan and move

i have a script to look for a file, but it moves a file that's being used.

i want to use:

if file exists > 0, and not being updated/used in the last 2 minutes, move to /tmp

i can do this much:

if [ -s filename.txt ]
then
mv filename.txt /tmp
else
exit
fi

or how can i check if filename.txt is being used ?
  #2 (permalink)  
Old 03-08-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
lsof or fuser will show if a file is open. You may have one or both on your system.
  #3 (permalink)  
Old 03-09-2009
zTodd zTodd is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 23
or If you need to check if a file's updated in the last x minutes whether it's open or not, you could maybe pipe output from
ls -l <file>
into a grep command to get the time, and check if that's in the last x minutes. (Not sure of the quickest way to do that right now)
  #4 (permalink)  
Old 03-10-2009
tjmannonline tjmannonline is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 91
fuser does the trick. thanks for your direction.
Sponsored Links
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 10:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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