Check if shell script is already running

One of my shell script was overlapping which resulted in 100% memory usage. So, I have written a validation that checks if the same shell script is running or not. If it’s not running it will continue to process further, otherwise exit. Below is the code snippet.

#!/bin/sh[ "$(pidof -x $(basename $0))" != $$ ] && exit## process further

Product Lead at StegoSOC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store