954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

script to move files that are not in use or open

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

jherrera
Newbie Poster
1 post since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

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
radoulov
Junior Poster in Training
54 posts since Feb 2007
Reputation Points: 10
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You