Re: Find existence of a proc

From: Dan Mercer (dmercer_at_mn.rr.com)
Date: 07/06/03


Date: Sun, 6 Jul 2003 12:46:26 -0500


"Juha Laiho" <Juha.Laiho@iki.fi> wrote in message news:be8q34$itp$2@ichaos.ichaos-int...
: "DL" <dl@internet.net> said:
: >I want to find out if a process is running on the system in a script by
: >"ps -ef | grep procname", but don't know how to test it, can some one show
: >me a piece of code?
:
: Others have already responded on how to test the result of "ps | grep",
: so nothing more on that.
:
: But something on the use of "ps": depending on your platform, you may be
: able to avoid some false positives by having "ps" just list the column
: you need:
: "ps -eo comm="
: ... and, if you know which account should be running that command,
: "ps -u acct -o comm="
:
: (the trailing "=" after the column name prevents display of the column
: header)
:
: On Linux this works by itself; on Solaris you need to use the
: /usr/xpg4/bin/ps . Don't know about the other variants (HP-UX, AIX, ...).

On HP-UX you must set UNIX95 (even to null works) to get xpg4 behavior.
Both HP-UX and Linux ps's support the -C option.

    Linux:

    ps -C httpd -o pid

on HP-UX

    UNIX95= ps -C httpd -o pid

Dan Mercer
dmercer@mn.rr.com

: --
: Wolf a.k.a. Juha Laiho Espoo, Finland
: (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
: PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
: "...cancel my subscription to the resurrection!" (Jim Morrison)



Relevant Pages

  • ksh and sh question
    ... I am trying to port ksh and sh shell scripts from HP-UX to Linux. ... I am trying to avoid script ...
    (linux.redhat)
  • perl win32 & output of printf
    ... In Perl win32 (ActivePerl v5.8.3), ... With the same script, under Linux & HP-UX, I got: ...
    (comp.lang.perl.misc)
  • boot.local in HP-UX
    ... I'm still learning HP-UX... ... My main background is Linux. ... script that will be executed every time the system starts? ...
    (comp.sys.hp.hpux)
  • Re: Will Linux become as vulnerable as MS ??
    ... > beeing vulnerable to viruses. ... > that they know are executable, and execute intentionally. ... >> Linux, each distro is a little different, and even within the distro, ... > Since clicking on a script is easier than typing it's name, ...
    (comp.os.linux.security)
  • wonk mode
    ... workable Linux system for my home computer, ... MEPIS release (replacing a much older "Fedora" ... Red Hat Package Monitor formatted software archives ... This little dandy script, line wrapped ...
    (comp.os.linux.misc)