On 25/10/10 9:33 PM, Tha.Suresh wrote:
  Sometimes we require a particular job to stop for a certain period
and start again.

Most of us familiar with the KILL command, But here is another cool
feature of the KILL command,

$ kill -STOP<pid>

$ kill -CONT<pid>

On the same context, an interesting shell script snippet that I remember using at my earlier organization (to tick off a bunch of
users who were running some wav to mp3 encoding tools on a
multi-user server) as below (save as schedule.sh and try):
------------------8<------------------8<--------
#!/bin/sh
SLEEPTIME=$1
shift
RUNTIME=$1
shift
PID="$*"

while true
do
    kill -STOP $PID
    sleep $SLEEPTIME
    kill -CONT $PID
    sleep $RUNTIME
done
----------------8<---------------------8<--------
To run at the shell prompt,
   pgrep lame | xargs ./schedule.sh 5 1

Have fun!

--
Chandrashekar Babu.,
http://www.chandrashekar.info/
http://www.slashprog.com/
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to