mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-25 23:47:53 +00:00
niceload: --prg implemented.
This commit is contained in:
parent
80d83aa489
commit
fd6044b0dc
|
@ -65,7 +65,11 @@ if(defined $opt::load) { multiply_binary_prefix($opt::load); }
|
||||||
my $limit = Limit->new();
|
my $limit = Limit->new();
|
||||||
my $process = Process->new($opt::nice,@ARGV);
|
my $process = Process->new($opt::nice,@ARGV);
|
||||||
$::exitstatus = 0;
|
$::exitstatus = 0;
|
||||||
if(@opt::pid) {
|
if(@opt::prg) {
|
||||||
|
# Find all pids of prg
|
||||||
|
my $out = `pidof -x @opt::prg`;
|
||||||
|
$process->set_pid(split /\s+/,$out);
|
||||||
|
} elsif(@opt::pid) {
|
||||||
$process->set_pid(@opt::pid);
|
$process->set_pid(@opt::pid);
|
||||||
} elsif (@ARGV) {
|
} elsif (@ARGV) {
|
||||||
# Wait until limit is below start_limit and run_limit
|
# Wait until limit is below start_limit and run_limit
|
||||||
|
@ -168,6 +172,7 @@ sub get_options_from_array {
|
||||||
"noswap|N" => \$opt::noswap,
|
"noswap|N" => \$opt::noswap,
|
||||||
|
|
||||||
"nice|n=i" => \$opt::nice,
|
"nice|n=i" => \$opt::nice,
|
||||||
|
"program|prg=s" => \@opt::prg,
|
||||||
"process|pid|p=s" => \@opt::pid,
|
"process|pid|p=s" => \@opt::pid,
|
||||||
"suspend|s=s" => \$opt::suspend,
|
"suspend|s=s" => \$opt::suspend,
|
||||||
"recheck|t=s" => \$opt::recheck,
|
"recheck|t=s" => \$opt::recheck,
|
||||||
|
|
|
@ -7,7 +7,7 @@ niceload - slow down a program when the load average is above a certain limit
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
B<niceload> [-v] [-h] [-n nice] [-I io] [-L load] [-M mem] [-N]
|
B<niceload> [-v] [-h] [-n nice] [-I io] [-L load] [-M mem] [-N]
|
||||||
[--sensor program] [-t time] [-s time|-f factor] ( command | -p PID )
|
[--sensor program] [-t time] [-s time|-f factor] ( command | -p PID [-p PID ...] )
|
||||||
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
@ -101,11 +101,20 @@ B<--noswap> will set both B<--start-noswap> and B<run-noswap>.
|
||||||
Sets niceness. See B<nice>(1).
|
Sets niceness. See B<nice>(1).
|
||||||
|
|
||||||
|
|
||||||
=item B<-p> I<PID>
|
=item B<-p> I<PID> (alpha testing)
|
||||||
|
|
||||||
=item B<--pid> I<PID>
|
=item B<--pid> I<PID> (alpha testing)
|
||||||
|
|
||||||
Process ID of process to suspend.
|
Process ID of process to suspend. You can specify multiple process IDs
|
||||||
|
with multiple B<-p> I<PID>.
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--prg> I<program> (alpha testing)
|
||||||
|
|
||||||
|
=item B<--program> I<program> (alpha testing)
|
||||||
|
|
||||||
|
Name of running program to suspend. You can specify multiple programs
|
||||||
|
with multiple B<--prg> I<program>.
|
||||||
|
|
||||||
|
|
||||||
=item B<--quote>
|
=item B<--quote>
|
||||||
|
|
|
@ -17,7 +17,7 @@ niceload - slow down a program when the load average is above a certain limit
|
||||||
@anchor{SYNOPSIS}
|
@anchor{SYNOPSIS}
|
||||||
|
|
||||||
@strong{niceload} [-v] [-h] [-n nice] [-I io] [-L load] [-M mem] [-N]
|
@strong{niceload} [-v] [-h] [-n nice] [-I io] [-L load] [-M mem] [-N]
|
||||||
[--sensor program] [-t time] [-s time|-f factor] ( command | -p PID )
|
[--sensor program] [-t time] [-s time|-f factor] ( command | -p PID [-p PID ...] )
|
||||||
|
|
||||||
@chapter DESCRIPTION
|
@chapter DESCRIPTION
|
||||||
@anchor{DESCRIPTION}
|
@anchor{DESCRIPTION}
|
||||||
|
@ -118,13 +118,23 @@ indication that the system is memory stressed.
|
||||||
|
|
||||||
Sets niceness. See @strong{nice}(1).
|
Sets niceness. See @strong{nice}(1).
|
||||||
|
|
||||||
@item @strong{-p} @emph{PID}
|
@item @strong{-p} @emph{PID} (alpha testing)
|
||||||
@anchor{@strong{-p} @emph{PID}}
|
@anchor{@strong{-p} @emph{PID} (alpha testing)}
|
||||||
|
|
||||||
@item @strong{--pid} @emph{PID}
|
@item @strong{--pid} @emph{PID} (alpha testing)
|
||||||
@anchor{@strong{--pid} @emph{PID}}
|
@anchor{@strong{--pid} @emph{PID} (alpha testing)}
|
||||||
|
|
||||||
Process ID of process to suspend.
|
Process ID of process to suspend. You can specify multiple process IDs
|
||||||
|
with multiple @strong{-p} @emph{PID}.
|
||||||
|
|
||||||
|
@item @strong{--prg} @emph{program} (alpha testing)
|
||||||
|
@anchor{@strong{--prg} @emph{program} (alpha testing)}
|
||||||
|
|
||||||
|
@item @strong{--program} @emph{program} (alpha testing)
|
||||||
|
@anchor{@strong{--program} @emph{program} (alpha testing)}
|
||||||
|
|
||||||
|
Name of running program to suspend. You can specify multiple programs
|
||||||
|
with multiple @strong{--prg} @emph{program}.
|
||||||
|
|
||||||
@item @strong{--quote}
|
@item @strong{--quote}
|
||||||
@anchor{@strong{--quote}}
|
@anchor{@strong{--quote}}
|
||||||
|
|
|
@ -3,10 +3,17 @@
|
||||||
# force load > 10
|
# force load > 10
|
||||||
while uptime | grep -v age:.[1-9][0-9].[0-9][0-9] >/dev/null ; do (timeout 5 nice burnP6 2>/dev/null &) done
|
while uptime | grep -v age:.[1-9][0-9].[0-9][0-9] >/dev/null ; do (timeout 5 nice burnP6 2>/dev/null &) done
|
||||||
|
|
||||||
sleep 1 &
|
sleep 2 &
|
||||||
PID1=$!
|
export PID1=$!
|
||||||
sleep 1 &
|
sleep 2 &
|
||||||
PID2=$!
|
export PID2=$!
|
||||||
sleep 1 &
|
sleep 2 &
|
||||||
PID3=$!
|
export PID3=$!
|
||||||
stdout /usr/bin/time -f %e niceload -l 8 -H -p $PID1 -p $PID2 -p $PID3 | perl -ne '$_ >= 5 and print "OK\n"'
|
echo '### multiple -p'
|
||||||
|
stdout /usr/bin/time -f %e niceload -l 9 -H -p $PID1 -p $PID2 -p $PID3 | perl -ne '$_ => 5 and print "Multiple -p OK\n"'
|
||||||
|
|
||||||
|
sleep 2 &
|
||||||
|
sleep 2 &
|
||||||
|
sleep 2 &
|
||||||
|
echo '### --prg'
|
||||||
|
stdout /usr/bin/time -f %e niceload -l 7 -H --prg sleep | perl -ne '$_ => 5 and print "--prg OK\n"'
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
OK
|
### multiple -p
|
||||||
|
Multiple -p OK
|
||||||
|
### --prg
|
||||||
|
--prg OK
|
||||||
|
|
Loading…
Reference in a new issue