Lots of logs to move....don't remove if open

I have a ksh script that currently moves a day's worth of log files (about 15,000) files to a different directory. The issue is that about 100 of these files are still open for write when this happens. I need an efficient way to ensure that these files aren't open without doing an lsof on each individual file within my loop. I think I need to get the list of open files once, and then check my outer loop against this list or array, but I'm not quite sure how to script that. Any assistance?
Thanks

Call lsof once, save its output, and check its output for the files you want. You could also craft a fixed list of files to avoid. Or simply send the services that refuse to give up their log files a signal to reopen them after.

Thank you. How do I take the saved output of file names and then compare them to the inputs of every file in the directory? I'd like to do something like

for every file in directory
do
if file not in (array or list of open files)
move it
done

for  file in /path/dir/*
do
  lsof | grep "$file"
  if [ $? -eq 1 ];then
      echo "$file safe to remove"
  if
done

You can also check using 'fuser' command (fuser <filename>)

How can I collect this post for future use without reply ?

Lots of logs to move....don't remove if open]Lots of logs to move....don't remove if open

[URLremove=http://www.unix.com/shell-programming-scripting/126241-lots-logs-move-dont-remove-if-open.html]Lots of logs to move....don't remove if open

normally I can find the post that I replied in my profile (Statistics), but if I am interested a post, and want to collect it only, how can I do?

In some forums, there is a star icon in the post, when I click it, I collect it, then I can find it in my profile.