How to check in a bash script if something is running and exit if it is

后端 未结 9 1953
悲&欢浪女
悲&欢浪女 2021-02-06 00:24

I have a script that runs every 15 minutes but sometimes if the box is busy it hangs and the next process will start before the first one is finished creating a snowball effect.

9条回答
  •  忘了有多久
    2021-02-06 00:45

    For a method that does not suffer from parsing bugs and race conditions, check out:

    • BashFAQ/045 - How can I ensure that only one instance of a script is running at a time (mutual exclusion)?

提交回复
热议问题