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

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