I have found this solution to do a process locking mechanism in python:
import socket
import sys
import time
def get_lock(process_name):
    global lock_socket
    lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
    try:
        lock_socket.bind('\0' + process_name)
        print 'I got the lock'
    except socket.error:
        print 'lock exists'
        sys.exit()
get_lock('running_test')
while True:
    time.sleep(3)
this was found here: Check to see if python script is running
Can the same be achieved in bash? If so, could someone please post a working example?
Many thanks
 
     
     
     
    