Quick-and-dirty way to ensure only one instance of a shell script is running at a time

前端 未结 30 2410
忘掉有多难
忘掉有多难 2020-11-22 02:57

What\'s a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time?

30条回答
  •  -上瘾入骨i
    2020-11-22 03:06

    Create a lock file in a known location and check for existence on script start? Putting the PID in the file might be helpful if someone's attempting to track down an errant instance that's preventing execution of the script.

提交回复
热议问题