I am working on a simple Spring console application (it is a litle batch working on a database).
This batch is scheduled to start at specific time. The problem is that the execution of this program can take a lot of time and the scheduler can try to start it before the previous instance of this program completed its work.
So I think that I can use a lock file to handle this situation, my idea is:
- When the batch start it check if there is this lock file in its folder (if this lock file is present, the batch application ends without doing anything).
- If the lock file can't be found: create the lock file and start the batch operations.
Do you think that it could be a valid approach to the problem? Or Spring provide some smarter way?
Another doubt is: what is the standard for a lock file? Can I create simply a .lock file in the current folder?