Ensure Only One Instance of a Bash Script Is Running

This page will generate script with lock files to ensure a second instance of a script does not run until the first is completed. Anytime you have multiple processes working with shared resources, using lock files will help avoid conflicts and race conditions.

This wizard will help you run linux script in singleton mode.

Put your original script bellow:

Result script:

How to prevent blocking on restart?

Add following to /etc/rc.local:

This page will help you when:

  • You want to know: How to make sure only one instance of a bash script runs?
  • how to use bash lock to block duplicate running scripts.
  • Ensure Only One Instance of a Bash Script Is Running