#!/bin/bash pidno=$( ps ax | grep /usr/bin/mythbackend | grep -v grep | grep -v mythbackend_monitor) # Checks for pid in "ps" listing, field #1. # Then makes sure it is the actual process, not the process invoked by this script. # The last "grep $1" filters out this possibility. if [ -z "$pidno" ] # If, after all the filtering, the result is a zero-length string, then # no running process corresponds to the pid given. echo "No such process running." mail david@thewhytehouse.org -s "MythTV Restart" < /var/log/mythtv/mythbackend.log /etc/init.d/mythtv-backend restart fi