Throttle a Process in Linux - My Ugly bash script - pause_run

Below is my script \"pause_run\" it will, in a VERY ugly way, throttle a process by pausing and running it.  Drop me a line if you actually use this! 

#!/bin/bash

# This script copied from check_ext_net on 2003-09-01 - although not much is left.
# By Leonard Chan (webdude@lc.yi.org)

# Pause_run takes three parameters.
#   1) seconds of pause time.
#   2) seconds of run time.
#   3) name of program to pause

# Programs are paused with \"killall -STOP [progname]\" and started with killall -CONT.
# Primary use for this is to attempt to keep the CPU cool on my old server during backups.
# I will \"pause_run\" either the tar or gzip processes (samba would screw up the network!)

#   sleep 10

# if not 3 params, give some instructions and exit.
# - I suppose $0 is the name of the script...
if [ $# -ne 3 ]
then
    echo \"Usage - $0 x y z\"
    echo \" x - pause seconds. y - run seconds. z - program to pause-run\"
    exit 1
fi

# do the pause-run two step.
echo \"To stop pause-run, you have to kill it.  (Ctrl+Break)\"

# loop somehow. well, 2 will never equal 3...
while [ 2 -ne 3 ]
do
 # pause the proggie
 killall -STOP $3
 # wait.
 sleep $1

 # run again
 killall -CONT $3
 # wait again
 sleep $2

done

Related Scribbles:
  • Pause a Process in Linux
  • Utilities
  • Throttle Processes Windows and Start Syntax
  • Linux Commands


  • ID: 281
    Author:
    leonard
    Date Updated:
    2003-12-23 00:22:55
    Date Created:
    2003-09-01 16:07:35

    Edit

    Comments?
     >> Leonard Chan's Homepage  >> Scribble Web  >> Throttle a Process in Linux - My Ugly bash script - pause_run
    leonard.lotus-land.ca is hosted by Perceptus Solutions Inc.