#!/bin/bash
current_time=$(date +%s)
ps axo lstart=,pid=,cmd= |
grep "puppet agent: applying configurat" |
while read line
do
# 60 * 60 is one hour, multiply additional or different factors for other thresholds
if (( $(date -d "${line:0:25}" +%s) < current_time - 60 * 60 * 1 ))
then
pid=`echo $line | cut -d ' ' -f 6` # change echo to kill
kill $pid
fi
done