Wednesday, May 24, 2023

Oracle Linux 7 -- How to Implement Singleton Scripts in Bash

Problem

You need to implement a singleton script in Bash, that is, a script that may have only single running instance

Solution

Use the singleton.sh utility script from https://github.com/pro-oracle/singleton

The script is aimed to help in implementation of singleton scripts, featured with automatic lock files clean up after abnormal script interruption, and also input parameters aware, different input parameters make different running instances of a script 

Usage:

Copy paste the content of singleton.sh into your script, or

#!/bin/bash
source singleton.sh

inside your script.


No comments: