pvalve - Control how much a given command should run by an other command's exit code



NAME

pvalve - Control how much a given command should run by an other command's exit code


SYNOPSIS

pvalve [<CONTROL COMMAND>] -- [<LONG RUNNING COMMAND>]

Controls when LONG RUNNING COMMAND should run, by pause and unpause it according to the CONTROL COMMAND's exit status.


DESCRIPTION

Pause LONG RUNNING COMMAND process group with STOP signal(7) if CONTROL COMMAND exits non-zero. Unpause LONG RUNNING COMMAND process group with CONT signal(7) if CONTROL COMMAND exits zero.

Pvalve takes the last line from CONTROL COMMAND's stdout, and if looks like a time interval (ie. positive number with optional fraction followed by optional "s", "m", or "h" suffix) then the next checking of CONTROL COMMAND will start after that much time. Otherwise it takes PVALVE_INTERVAL environment variable, or start next check immediately if it's not set.

Pvalve won't bombard LONG RUNNING COMMAND with more consecutive STOP or CONT signals.


USEFULNESS

It's useful eg. for basic load control. Start a CPU-intensive program in LONG RUNNING COMMAND and check hardware temperature in CONTROL COMMAND. Make it exit 0 when temperature is below a certain value, and exit 1 if above an other, higher value.


ENVIRONMENT

PVALVE_INTERVAL

Default interval between two CONTROL COMMAND runs.

PVALVE_STATUS

PVALVE_STATUS describes whether LONG RUNNING COMMAND should be in running or in paused state. Possible values: RUN, STOP. This environment is available by CONTROL COMMAND.


CAVEATS

Further process groups which are created by LONG RUNNING COMMAND will not be affected.

 pvalve - Control how much a given command should run by an other command's exit code