use Fcntl ':flock'; my $lockfile = "/var/lock/frobnitz"; open $lh, "+<", $lockfile or die $!; flock $lh, LOCK_EX or exit; sleep 600; exit;