We are facing a problem in our monitor script.
The flow of the program is
- Customer ftp/sftp the file (in .csv format) to "source" directory
- Bash script renames the completed .csv file to .aaa file
- Another Bash script moves the ".aaa" file to "destination" directory and renames the file back to ".csv"
- CAMEL is monitoring the "destination" directory. If any file comes to "destination" folder and having extension not equal to ".aaa" it will start processing the file.
Here the step 3 is failing. Bash script moves the file successfully. But while renaming the file from ".aaa" to ".csv" CAMEL fetches the file and start processing. CAMEL fails with the error "the footer is not present". This is because the "mv" command was not complete and CAMEL processed before the "mv" is completed. So it processed an incomplete file.
Since we use scripting we have little flexibility in using the commands. We are using Linux "mv" command to rename the file.
Is there a way to lock the file in scripting while renaming which will stop the CAMEL from accessing it?
Or is there a better way of handling this scenario?
Appreciate the help in advance.
Thanks, Mathew Liju