kill($pid,$sig)
Will kill the given process id. If $sig is specified it will kill with the given signal.
task "kill", "server01", sub {
kill 9931;
kill 9931, -9;
};
killall($name,$sig)
Will kill the given process. If $sig is specified it will kill with the given signal.
task "kill-apaches", "server01", sub {
killall "apache2";
killall "apache2", -9;
};
ps
List all processes on a system. Will return all fields of a psaux.
task "ps", "server01", sub {
for my $process (ps()) {
say "command > " . $process->{"command"};
say "pid > " . $process->{"pid"};
say "cpu-usage> " . $process->{"cpu"};
}
};
On most operating systems it is also possible to define custom parameters for ps() function.
task "ps", "server01", sub {
my @list = grep { $_->{"ni"} == -5 } ps("command","ni");
};
This example would contain all processes with a nice of -5.
nice($pid,$level)
Renice a process identified by $pid with the priority $level.
task "renice", "server01", sub {
nice (153, -5);
};
perl v5.40.0 2025-02-06 Rex::Commands::Process(3pm)