Not strictly a Linux question, but it could be just as relevant on a Linux system.
I have a client with a SCO SYSV Unix Box running a legacy Accounting system. It is a korn shell.
They have a Windows based Print Workflow system (called StreamServe I believe) that takes print jobs from a spool folder and prints or emails Credit account statements generated by the Accounting package.
Unfortunately the way the queue works is that once a job has been processed by streamserve it is deleted from the queue folder on the Unix box by the streamserve application. The problem is that it is very difficult and time consuming to regenerate the reporting run if something fails upstream of the Streamserve box resulting in lost prints. (this is what happened the other day)
I can't tell the streamserve application to not delete the processed jobs as it simply prints whatever is in the queue every time it polls.
The Streamserve box looks for a particular file extension before processing the file. I can change the file extension that the Streamserve looks for.
So my plan is to change this extension and then have a script that looks for jobs (of the original extension) in the queue and copies them to a archive area before renaming them to a pattern that the (modified) streamserve application is looking for. It is important that I don't introduce any delay of more than a minute or so into the workflow but the print files rarely exceed a couple of MB so that shouldn't be a problem.
I could just knock together a script that does this from Cron but in order to not introduce too much of a delay it would have to run about once a minute.
This box is quite heavily loaded sometimes and it is of limited performance anyway. So my question is-
What is the most efficient way to "watch" a folder for a particular file pattern, if I have a looping "if exist" script is this likely to consume lots of resources as surely it would be continuously polling the disk to check for that file.
Is it good practise to do this (perhaps with some sort of introduced delay in the loop) or is there a better/cleaner/more efficient way.
Regards Wayne