1Rex::Commands::Process(U3s)er Contributed Perl DocumentatRieoxn::Commands::Process(3)
2
3
4
6 Rex::Commands::Process - Process management commands
7
9 With this module you can manage processes. List, Kill, and so on.
10
11 Version <= 1.0: All these functions will not be reported.
12
13 All these functions are not idempotent.
14
16 kill $pid;
17 killall "apache2";
18 nice($pid, $level);
19
21 kill($pid, $sig)
22 Will kill the given process id. If $sig is specified it will kill with
23 the given signal.
24
25 task "kill", "server01", sub {
26 kill 9931;
27 kill 9931, -9;
28 };
29
30 killall($name, $sig)
31 Will kill the given process. If $sig is specified it will kill with the
32 given signal.
33
34 task "kill-apaches", "server01", sub {
35 killall "apache2";
36 killall "apache2", -9;
37 };
38
39 ps
40 List all processes on a system. Will return all fields of a ps aux.
41
42 task "ps", "server01", sub {
43 for my $process (ps()) {
44 say "command > " . $process->{"command"};
45 say "pid > " . $process->{"pid"};
46 say "cpu-usage> " . $process->{"cpu"};
47 }
48 };
49
50 On most operating systems it is also possible to define custom
51 parameters for ps() function.
52
53 task "ps", "server01", sub {
54 my @list = grep { $_->{"ni"} == -5 } ps("command","ni");
55 };
56
57 This example would contain all processes with a nice of -5.
58
59 nice($pid, $level)
60 Renice a process identified by $pid with the priority $level.
61
62 task "renice", "server01", sub {
63 nice (153, -5);
64 };
65
66
67
68perl v5.36.1 2023-08-07 Rex::Commands::Process(3)