0

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

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by radoulov
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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.