Operating System - HP-UX
1821062 Members
2453 Online
109631 Solutions
New Discussion юеВ

Retrieving the full command name with "ps" command

 
Sekhar_3
New Member

Retrieving the full command name with "ps" command

Hello,

I want to know whether particular perl script is running or not on HP-UX10.20 system. If use
ps -ef | grep -v "grep" | <script name> it is displaying nothing eventhough the script is running. If use wild character "*" in the script name it is displaying the output but I found that the script name is getting truncated at the end. I think there would be limitation in displaying the command name.If the command name is too big then it will truncate the command name.

In HP-UX11.11 I found the "-x" option in ps command which displays the full command name.

Can any body help me out the for the similar option in HPUX10.20 like "-x".

Thanks
Sekhar.
14 REPLIES 14
Patrick Wallek
Honored Contributor

Re: Retrieving the full command name with "ps" command

As far as I know the '-x' option does not exist in HP-UX 10.20, not even with a patch.

There may be a gnu version of ps you could try, but I am not certain and I don't know if that would even help you.
Jakes Louw
Trusted Contributor

Re: Retrieving the full command name with "ps" command

As far as I know, HP-UX has no facility for an extended "ps" output.

Could be very useful.

Maybe somebody at Tech Development Labs is reading this thread? ;->
Trying is the first step to failure - Homer Simpson
Ravi_8
Honored Contributor

Re: Retrieving the full command name with "ps" command

Hi Sekhar

In 10.20 you can use ps -f to display full command
never give up
Jakes Louw
Trusted Contributor

Re: Retrieving the full command name with "ps" command

As far as I know, "ps -f" will only give a different column view, but it still chops the display.
Trying is the first step to failure - Homer Simpson
Elmar P. Kolkman
Honored Contributor

Re: Retrieving the full command name with "ps" command

If you take a look at the manual of the ps command, you'll see why the line will be truncated:
'Only a subset of the command line is saved by the kernel'
Since ps takes its data from the kernel, you'll only see a subset.

Thus, if you want the complete command line, it won't work. But if you're only interested in the command name, try using the -l option instead of the -f option. Or use the XPG4 version (set the UNIX95 environment variable before running ps) and use the '-o comm' option.

Perhaps there is someone out there who knows a kernel parameter to extent the kernel command buffer?
Every problem has at least one solution. Only some solutions are harder to find.
Rory R Hammond
Trusted Contributor

Re: Retrieving the full command name with "ps" command

The syntax you have show should not work.
on less you are sending output to a script.

ps -ef | grep -v "grep" | <script name>

should be
ps -ef |grep -v "grep" |grep <script name>

Unfortunatly I don't know of 10.2 or 11.0 way
to get extended command line.
if you are executing the script via full path name. you might cd to the directory and then
execute your script

Rory

There are a 100 ways to do things and 97 of them are right
Bill Hassell
Honored Contributor

Re: Retrieving the full command name with "ps" command

ps -x is a feature added via a patch for 11.x systems only. It was never a part of 10.20 which has been obsolete since 2001 and unsupported since last summer. There is no way to get the entire command line in ps for 10.20 systems. You'll have to start processes that have long pathnames in a script that uses $PWD to shorten the command line.


Bill Hassell, sysadmin
Jakes Louw
Trusted Contributor

Re: Retrieving the full command name with "ps" command

Thanks, Bill.

Do u have that patch ID on the tip of your tongue, perhaps?
Trying is the first step to failure - Homer Simpson
Bill Hassell
Honored Contributor

Re: Retrieving the full command name with "ps" command

PHCO_26274 will add the -x option to ps (for 11.0) and PHCO_29042 adds the feature for 11.11.


Bill Hassell, sysadmin
Jeroen Peereboom
Honored Contributor

Re: Retrieving the full command name with "ps" command

Sekhar,

have a look at the ps man page for UNIX95 options. For example: export UNIX95=1;ps -A -o comm=
It will show the command in a different way. Maybe this may help.

JP
T. M. Louah
Esteemed Contributor

Re: Retrieving the full command name with "ps" command

try these
# UNIX95=1 ps -eo vsz,ruser,pid,args |sort -rn |more
# UNIX95=1 ps -eo vsz,ruser,pid,comm |sort -rn |more
-- or
# UNIX95=1 ps -eo vsz,ruser,pid,ppid,args |sort -rn |more

cheers
Little learning is dangerous!
Bill Hassell
Honored Contributor

Re: Retrieving the full command name with "ps" command

Note that invoking ps with UNIX95 allows you to specify the fields you'd like to see (ie, -o comm and -o args) but the kernel's internal field for the command line is still limited. Without patches to change the maximum size of this field, ps cannot see the entire command line. Therefore, for 10.20 there is no way to access more than about 60 characters of the comand line.


Bill Hassell, sysadmin
Sekhar_3
New Member

Re: Retrieving the full command name with "ps" command

Thanks to one and all.
Jakes Louw
Trusted Contributor

Re: Retrieving the full command name with "ps" command

Assign points!
Trying is the first step to failure - Homer Simpson