RSS Forums RSS
Please support our Shell Scripting advertiser: Programming Forums
Views: 2022 | Replies: 1 | Thread Tools  Display Modes
Reply
Join Date: Sep 2007
Posts: 1
Reputation: jherrera is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jherrera jherrera is offline Offline
Newbie Poster

script to move files that are not in use or open

  #1  
Sep 25th, 2007
hello,

I try to make a script to move files that are not in use or open by another program or process. it is kind of cleanup script. I need to cleanup some log-files that are not in use by the programs.

i know that they are tools to check this files ( lsof and fuser) but I don 't see or find any good (simple) example to move files from one directory to another without the open /used files ?

thanks in advance,

Jonay
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Posts: 52
Reputation: radoulov is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
radoulov's Avatar
radoulov radoulov is offline Offline
Junior Poster in Training

Re: script to move files that are not in use or open

  #2  
Sep 26th, 2007
Originally Posted by jherrera View Post
I try to make a script to move files that are not in use or open by another program or process. it is kind of cleanup script. I need to cleanup some log-files that are not in use by the programs.

i know that they are tools to check this files ( lsof and fuser) but I don 't see or find any good (simple) example to move files from one directory to another without the open /used files ?


Adjust *.log for your needs (you may include the path: /your/path/*.log):

 for f in *.log;do fuser "$f">/dev/null 2>&1||rm -- "$f";done
Last edited by radoulov : Sep 26th, 2007 at 6:14 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:55 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC