Keep crontab from escaping each other?

If you have a crontab job that runs every 5 minutes, how do you guarantee that it never overflows itself? That is, how do you make sure that the previous iteration of the crontab job is completed before the next start?

+3
source share
2 answers

at the beginning of your script, create a unique temp file somewhere in the file system if the file no longer exists, in which case your script is already running, and you should exit. at the end of your script, delete the unique temp file.

There are other options for this, I'm sure, but they all have a similar idea. if you like this answer, check the box next to it. thank!

+2
source

. , dqhendricks.

+1

Source: https://habr.com/ru/post/1782803/