use strict; use warnings; my $app = 'nscd'; print "Looking for '$app'\n"; while (1) { open PS, "ps -ef |" || die "Cannot open ps command: $!\n"; my @cmd = grep { /$app/ } ; close PS; last unless @cmd; print "'$app' is still running ...\n"; sleep 2; } print "'$app' is finished.\n";