App-RunStopRun

 view release on metacpan or  search on metacpan

bin/run-stop-run  view on Meta::CPAN

Options:
  -v, --verbose       Be verbose
  -n, --dry-run       Dry run, don't run command or send signals

  -l, --limit PERCENT Limit runtime to between 1..99 (default: 50.0)
  -r, --run SECONDS   Run the process for SECONDS (default: 1.0)
  -s, --stop SECONDS  Stop the process for SECONDS
  -p, --pid PIDS      Operate on PIDS
  -c, --children      Operate also on all child processes of the PIDs
  -g, --group         Operate on the process groups of the PIDs
  -G  --no-group      Don't create a new process group or determine PGIDs
  -T, --no-tty        Disable pseudo-terminal allocation
  -t, --tty           Force pseudo-terminal allocation

  -V  --version       Display the version number
  -h, --help          Display this help message
  -H, --man           Display the complete documentation
    END_OF_OPTIONS

    exit(@_ ? 2 : 0);
}


__END__

=head1 NAME

run-stop-run - limit CPU usage of processes

=head1 SYNOPSIS

  run-stop-run [options] command [arguments]
  run-stop-run [options] -p PID,-PGID

=head1 DESCRIPTION

This program controls the CPU usage of processes by repeatedly sending SIGSTOP
and SIGCONT signals. It can be used to run a command or on the PIDs of
already-running processes.

It is useful in the case that you have a long-running CPU-intensive process
and want to maintain a thermal limit (think fanless computer). Or you may have
a program that uses all cores without providing a means to configure the level
of concurrency.

=head1 OPTIONS

=over 4

=item B<-v>, B<--verbose>

Be verbose.

=item B<-n>, B<--dry-run>

Don't send any signals, just print the command (if given), or list the
PIDs/PGIDs it would affect.

=item B<-l>, B<--limit> I<PERCENT>

The percent of time to run. The default value is 50.0; possible values are
1..99. Specify this with only one of B<--run> or B<--stop>. The other will be
derived.

=item B<-r>, B<--run> I<SECONDS>

The number of seconds to run. The default value is 1.0. Specify this with only
one of B<--limit> or B<--stop>. The other will be derived.

=item B<-s>, B<--stop> I<SECONDS>

The number of seconds to stop. Specify this with only one of B<--limit> or
B<--run>. The other will be derived.

=item B<-p>, B<--pid> I<PID,-PGID>

A list of PIDs of already-running processes. The list may be comma-separated
or the option given multiple times. If the PID is negative, it is interpreted
as a process group.

=item B<-g>, B<--group>

Operate on the entire process group. This is the default when running
a command, as it will start a new process group. When operating on a list of
PIDs, it will determine the associated process groups and operate on them
directly.

=item B<-G>, B<--no-group>, B<--nogroup>

Don't create a new process group for the command to run. When operating on
a list of PIDs, it will not determine associated process groups and operate on
them, but it will still operate on any given PGIDs.

Note that creating a new process group causes the command to be run in the
background, and some commands refuse to print if they are not the foreground
process (ex. newer versions of B<pv>). In this case, you will also have to
disable pseudo-terminal allocation, as that results in a call to C<setsid()>,
which creates a new process group.

=item B<-c>, B<--children>

Operate on all descendent processes of the command or PIDs. These are found by
scanning the process table and checking the parent process and group of each
process. Note that it's not always possible to determine the parentage, since
the process might have double-forked and changed it's process group.

=item B<-T>, B<--no-tty>, B<--notty>

Disable pseudo-terminal allocation.

=item B<-t>, B<--tty>

Force pseudo-terminal allocation. Specifying this more than once will force
allocation even if there is no attached terminal.

=item B<-V>, B<--version>

Display the version.

=item B<-h>, B<--help>



( run in 1.513 second using v1.01-cache-2.11-cpan-39bf76dae61 )