How to fetch all running services on HP-UX?

Hi All,

I have a requirement to get all the running services on few HP-UX boxes. In Linux systems I am able to do that successfully using: chkconfig --list. However I can't find anything equivalent in HP-UX. If anyone has any pointers on the same then please suggest.

Adyan

HP-UX 11 does not register services anywhere.
Since this has been asked before, I have made a script that tries to emulate it:

#!/bin/sh
cd /sbin/init.d || exit
UNIX95=1 ps -e -o ppid= -o args= |
LC_ALL=C awk '
{
  if (NR==FNR) {
    if ($1==1 && !($0 in s)) {
      s[$0]
      sub(".*/","",$2); sub(".*/","",$3)
      out=out sep ((length($2)>4 || $3!~/^[a-zA-Z]{3}/) ? $2 : $3)
      sep="|"
    }
  } else {
    if (FILENAME!=pfilename && $0~"(^|^[^#]*[/ ,|])(" out ")([ ,|]|$)") {print pfilename=FILENAME}
  }
}
' - *

It looks for the currently running processes with ppid=1, greps the process names in /sbin/init.d/*, and returns the matching files in /sbin/init.d.

2 Likes

Thank you sir, you have saved me time which matters the most these days :slight_smile:

I have refined my script, comments are now excluded from the search.

Thx a lot MadeInGermany ..