I need some help with an interface on a Linux machine (RedHat AS4) but I am no expert in the Bash shell. If this was Windows, I would have no problem writng the batch file to do the job.
Here's the situtation: We have a purchased Windows application that creates *.xml interface files and copies them to a directory on a Network Appliance filer on our network that our Linux/Oracle server can monitor (via an nfs mount). When new files are available there, I need Linux to move them locally, then tell Oracle to process them. This will typically be a dozen or maybe a couple dozen files per day, ranging in size from just a few KB to about 10MB each. There may be just one file at a time, or there could be multiple files.
I think I need a cron job to run at frequent intervals (maybe every 2 - 5 minutes) to do these steps:
1. look for files like "CARSEQ_XML[xxx][yyyy].xml
" in /source_dir
2. if found, make sure it is not still being written to (wait a few seconds and try again if locked)
3. if complete, move it locally, and tell Oracle to process it
I know how to set up a cron job and I know how to write the last part: "move it locally, and tell Oracle to process it". I need help with the other parts.
When I tested yesterday by manually copying a large (500MB) file from WIndows, then trying an "mv" command in Linux on that same file, it gave me "permission denied" while it was still being written to, but as soon as the copy was complete, the "mv" succeeded. I don't know though in a Bash shell script how to test for success or failure of an "mv" command. Or, is there a better way?
Start Free Trial