[mythtv-users] mythbackend pid

Steven Adeff adeffs.mythtv at gmail.com
Sat Jun 30 20:08:57 UTC 2007


On 6/29/07, Brad DerManouelian <myth at dermanouelian.com> wrote:
> On Jun 29, 2007, at 6:23 PM, dropax wrote:
>
> > You can use the PID from the pid file to check whether that process is
> > still running.  Linux ubernewbie here only knows that the "top"
> > command
> > shows pid, but I'm sure there are other commands which show active
> > processes with less overhead or in a more easily parsed format.
>
> This is how I would do it:
>
> [mythtv at mythtv ~]$ perl -e '$pid=`ps -ae | grep mythbackend`; $pid
> =~ /^(\d+)/;print $1;'
> 27989[mythtv at mythtv ~]$
>
> That should print out the pid of the currently running mythbackend
> process. If you exit abnormally or $pid doesn't match what the
> pidfile says, it's dead. You don't even need the pid, actually. If
> that command exits abnormally it means $pid is null and the regex
> will bail which means the backend is not running.
>
> To paraphrase The Minutemen: hack! hack! hack!


I prefer pgrep,
# pgrep
pgrep: No matching criteria specified
Usage: pgrep [-cflvx] [-d DELIM] [-n|-o] [-P PPIDLIST] [-g PGRPLIST]
[-s SIDLIST]
        [-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] [PATTERN]

so
$ pgrep mythbackend
7262

or
$ pgrep -l mythbackend
7262 mythbackend

theres also pkill,
$ pkill
pkill: No matching criteria specified
Usage: pkill [-SIGNAL] [-fvx] [-n|-o] [-P PPIDLIST] [-g PGRPLIST] [-s SIDLIST]
        [-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] [PATTERN]

so for example,
pkill -9 mythbackend
would kill the backend

-- 
Steve
Before you ask, read the FAQ!
http://www.mythtv.org/wiki/index.php/Frequently_Asked_Questions
then search the Wiki, and this list,
http://www.gossamer-threads.com/lists/mythtv/
Mailinglist etiquette -
http://www.mythtv.org/wiki/index.php/Mailing_List_etiquette


More information about the mythtv-users mailing list