[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: a quick Q: how to start run a job after another job finished

>> On Thu, 6 Oct 2011 23:12:46 +0800, 
>> lina <lina.lastname@gmail.com> said:

L> I want to run a job after checking another job finished or not, such as
L> another job PID is 5543.  If it's finished then run newjob.sh

   If you own the other process (or you're root) you can use signal 0 to
   verify that it's still alive:

     me% sleep 60 &
     [1] 10175

     me% kill -0 10175                          [$? = 0]

     me% kill -0 10176
     kill: kill 10176 failed: no such process   [$? = 1 or 2]

   Try this:

     pid=5543  # or $1 or whatever
     while kill -0 $pid 2> /dev/null; do
         sleep 60

Karl Vogel                      I don't speak for the USAF or my company

Taxation WITH representation isn't so hot, either.        --bumper sticker

Reply to: