I have a BASH script that is kicked off via CRON. It checks to see if any new file has arrived. If so, it unzips the file via gunzip.
The problem is that if the file is very large (i.e. 5gb+) the script will not finish before cron launches a new instance. Now I have two instances trying to unzip the same file.
So, my solution is to touch .file.ext.lock and then try to unzip. When the unzip is done, I rm -f .file.ext.lock. That way, if another instance wakes up and finds the lock file, it will just echo that a lock file exists and exit.
I was wondering if this is the best way to do it though. Do you see any flaws in this and if so, how would you go about resolving the flaws.
2006-10-11
17:56:58
·
2 answers
·
asked by
thepinky
3
in
Computers & Internet
➔ Programming & Design