[Chicago-talk] Determining if another perl process is running.
Steven Lembark
lembark at wrkhors.com
Wed Dec 18 10:07:55 PST 2024
qx{ pgrep -a -f 'starman.*<your args here>' }
e.g., if you started it on pot 8080:
chomp{ my @found = qx{ pgrep -a -f 'starman.*8080' } );
say "Running process: $_" for @found;
leave out the '-a' and you'll just get a set of integer process ID's:
my @pidz = qx{ pgrep -f 'starman.*8080' };
if you want to, say, restart the service:
my $pid = qx{ pgrep -f 'starman.*master.*8080' };
kill HUP => $pid;
Yes, you could make this a one-liner :-)
--
Steven Lembark
Workhorse Computing
lembark at wrkhors.com
+1 888 359 3508
More information about the Chicago-talk
mailing list