At work, we have an cron job in Bash which can sometimes take a long time to run, depending on some external conditions. So, it was therefore possible that script would not be finished before its next execution. In our case, we really didn't want this to happen, as it could have corrupted some sensitive data if two instances were running at the same time... 🤢
So, one way to ensure that only one instance is running is to introduce the concept of a lock. Fortunately, it was much easier than we think to implement, thanks to a Stack Exchange answer by Sethu. 🥳
A powerful line, right? 😉
Top comments (0)