function stat_logfile() { awk '/Modify/ {print $3}' <<< "$(stat "$LOG_FILE")" } function get_line_count() { awk 'END{print NR}' "$LOG_FILE" } function check_stall() { newlines=$(stat_logfile) while ps -p $(/dev/null; do # Check for transcode output every 10 seconds sleep 10 age=$newage newage=$(stat_logfile) # If no new output, sleep 20s and check again [[ $newage = $age ]] && sleep 20 && newage=$(stat_logfile) # If still no new lines, send a HUP signal to transcode if [[ $newage == $age ]]; then echo echo "*** transcode appears to be stalled ***" echo "*** We are going to send transcode a HUP and hope for the best ***" # make sure pid still active if $(ps -p $(/dev/null); then $(kill -0 $( /dev/null 2>&1) && kill -HUP $(