I'm looking for a fool-proof way to ensure that at most 1 copy per user is running of a single Perl script. This code is horribly ugly and needs to be scheduled frequently via cron but occasionally may run for a very long time. I'd like to ensure that if a copy is already running, another one doesn't start up. I need to do this with very minimal changes to the running code (as I said, it's ugly and already does a very poor job of error handling). Any ideas would be greatly appreciated. The developer had this coded in there, but it's not always working correctly: my $My_Name = getlogin || (getpwuid($<))[0]; my $ProgName = 'ftphandler.pl'; # update if program name changes # check to see if user is already running program my $Running=`ps -ef|grep $My_Name | grep perl | grep -c $ProgName`; chop($Running); if ($Running > 2) { #print "already running.\n"; unlink("$Tmplog"); exit; } It's not my code, but I get to be the lucky guy to fix it and I'm a crappy Perl coder... Thanks, .../Ed -- Ed Wilts, RHCE Mounds View, MN, USA mailto:ewilts@xxxxxxxxxx Member #1, Red Hat Community Ambassador Program