I’ve a shell script which list files of a folder and then do an action on them(print into a PDF), but very often I get a blank PDF. If I remove the generated PDF, the new PDF is always correctly generated.
I’ve the impression that is because my script started to print BEFORE the file has been fully copied(the copy is made through the OS explorer, with a save as, or just copy-paste).
It’s absolutely not me which manage when someone add a new file, the copy comes from users which uses a network share.
so is there a way to have something like this?
for inputFile in `ls -l $SearchPattern | grep ^- | awk '{print $9}'`
do
//CHECK_THAT_THE_FILE_HAS_ALREADY_BEEN_FULLY_SAVED_ONCE
//DO_MY_PRINT_HERE
done
I ended by using
the -cmin +1 indicate to find, that is has to list only file with the modification time >1min ago.
It’s not 100% safe, but it will handle all my case with a lot of margin.
I didn’t find how to do this in seconds