WordPress Developer & Linux Administrator

executed

How to determine if bash script is running from within the script

Often times when running a bash script, you don’t want it to be executed on a cron (again) if it’s already running. This little trick will show you how to code a contingency into your script so that it doesn’t doubly or triply execute while the first script instance is running.

Typically this involves using a temp or lock file, so that you can easily track the status of the script. I’m going to show you two examples.

Continue Reading