I have two scripts let's call them script1 and script2.
The script1 is scheduled every 2 minutes and it takes 4 minutes to execute the script2 is scheduled every 30 minutes and it takes 4 minutes to execute. At the moment I'm using flock within the scripts to assure that script1 and script2 never run concurrently. However the exclusiveness of the write lock cause the script1 to never be executed concurrently as well.
In my case I would like to allow parallelism of script1 and non concurrency with script2. If I use read lock between the instances of script1 the problem is that I will cause a starvation for script2 that it will never be executed.
Is there a clever way to do that?
That is once a write lock is asked the following read lock are not granted? Because this is the problem while script2 wait for a write lock there are other instances of script1 that are able to get the read lock and the script2 instance wait for ever