use Fcntl 'LOCK_EX', 'LOCK_NB'; unless (flock DATA, LOCK_EX | LOCK_NB) { $logger->fatal("Found duplicate script run. Stopping"); exit; } __DATA__ This exists to allow the locking code at the beginning of the file to work. DO NOT REMOVE THESE LINES!