[kanchilug] Re: [Tip] Temporarily stop/start a process in linux

  • From: "Tha.Suresh" <jemenisuresh@xxxxxxxxx>
  • To: KanchiLug <kanchilug@xxxxxxxxxxxxx>, iitdlug@xxxxxxxxxxxxxxxx
  • Date: Tue, 26 Oct 2010 19:28:57 +0530

---------- Forwarded message ----------
From: Chandrashekar Babu <lug@xxxxxxxxxxxxxxxxxx>
Date: Tue, Oct 26, 2010 at 6:13 PM
Subject: Re: [Ilugc] [Tip] Temporarily stop/start a process in linux
To: ilugc@xxxxxxxxxxxxx


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



-- 
Regards,
Tha.Suresh

Kanchi Linux User Group Rocks !!!!
http://kanchilug.wordpress.com

My experiences with Linux are here,
http://thasulinux.wordpress.com

Other related posts: