I had a similar problem with my solar monitoring project. (No sun=> no reaction from inverter => waiting until sun comes up...grrr)

I solved it using:
Code:
"Some time consuming command"
PID=$!
usleep 1000
if [ -d /proc/$PID ]
then
  kill $PID
fi