Introducción: Para evitar que una instancia de script de bash se ejecute más de una vez al mismo tiempo, aquí hay un pequeño consejo sobre cómo escribir el script.
Plantilla de guión: #!/bin/bash
# Prevents that an instance of the script starts while another instance of it is still running
scriptname=$(basename $0)
lockfile="/tmp/${scriptname}.lock"
if [ -e $lockfile ]; then exit 1 ; fi
touch $lockfile.lock
# Delete lock file if CTRL-C typed from the keyboard
trap 'rm $lockfile ; exit' SIGINT SIGQUIT
#----------------------------------
# ############ Put your script code here #####################
#----------------------------------
# delete the lock file
rm $lockfile
# .eof