Show running process command > 60 chars

Hi.

I use this command to get list of running process:

ps -ef|grep ICP|grep -v grep

But how do I set the terminal to show full command? It seems that it always truncated to 60 chars no matter what options I put.

e.g output

oracle9 25011 24998  0 03:00:05 ?         0:00 /usr/bin/sh /bistari/dw/iodds1/oradata/load/ICP/load_incr_ic

whereby there are several other load_incr_ic inside that directory which might belong to someone else's script.

Thank you.

Does it show all processes truncated? Or does it just truncate processes that belong to someone else? Does it always truncate your processes?

What OS are you on, what shell (bash, zsh, ksh...etc.)?

That behavior can be system specific - truncating command lines in ps.

Did you try ps | less to check the length of lines then? Did you try COLUMNS=600 ps ?

This does not solve your problem, but removes one grep

ps -ef | grep CP

should give the same as

ps -ef | grep ICP | grep -v grep

Should be quoted, to avoid a match in the current work directory (in this case only saves some I/O operations)

ps -ef | grep 'CP' 

Most efficient is pgrep.
The limited length of shown arguments is OS-specific.

Thanks all for your response.

But it seems there is no proven solution yet. :frowning:

OK, I am telnetting to HP-UX s34klj69 B.11.00 U 9000/800 (th)

It is using sh mode I think.

So, the problem is I want to kill my job if it hangs and runs for a very long time. So, the part of the job command is ICP. So, here is what happens as in the screenshot attached..

Actually the 60 chars thing I found out after been googling about this issue :frowning:

Please help.

Thanks.

---------- Post updated at 11:56 AM ---------- Previous update was at 11:56 AM ----------

By the way, how do I sort the grep command to sort the last column i.e. the running command?

Thank you.

From ps - HP-UX

           -f             Show columns user, pid, ppid, cpu, stime, tty,
                          time, and args, in that order.

...

           args           The command line given when the process was
                          created.  This column should be the last one
                          specified, if it is desired.  Only a subset of the
                          command line is saved by the kernel; as much of
                          the command line will be displayed as is
                          available.  The output in this column may contain
                          spaces.  The default heading for this column is
                          COMMAND if -o is specified and CMD otherwise.

Regards,
Alister

In HP-UX, you can try -x option to show command line in extended format.

ps -efx

As Alister mentioned above, you can display args alone using -o option:

UNIX95=1 ps -ae -o args

Make sure you set UNIX95 variable to use the XPG4 environment instead of the HP-UX environment.

Pipe the O/P to sort command to get sorted args result.

Thanks but I still can't find which option to use :frowning:

---------- Post updated at 01:28 PM ---------- Previous update was at 01:27 PM ----------

Thanks..

but..

$ ps -efx|grep ICP|grep -v grep
ps: illegal option -- x

:frowning:

I do have it:

$ ps -efx | grep tivoli
    root  4605  4603  0  Mar 14  ?        450:44 /opt/tivoli/ep/_jvm/bin/PA_RISC2.0/tca -Xmx384m -Xminf0.01 -Xmaxf0.4 -Djava.net.preferIPv4Stack

OS version:

$ uname -s -r -v -m
HP-UX B.11.23 U 9000/800

ps version:

$ what /usr/bin/ps
/usr/bin/ps:
        $Revision: 92453-07 linker linker crt0.o B.11.16.01 030415 $
         ps.c $Date: 2005/05/30 03:42:36 $Revision: r11.23/4 PATCH_11.23 (PHCO_32475)
         $Revision: @(#) ps R11.23_BL2005_0530_2 PATCH_11.23 PHCO_32475

What version are you using? Also check your man pages.

---------- Post updated at 01:19 ---------- Previous update was at 01:13 ----------

Never mind, I did some research and discovered that -x option is only available starting with HP-UX 11.11

Thanks yoda..

As expected, mine is lower..

$ uname -s -r -v -m
HP-UX B.11.00 U 9000/800
$ what /usr/bin/ps
/usr/bin/ps:
         ps.c  $Revision: 82.1.1.2 $ $Date: 99/04/29 00:13:07 $
         PATCH_11_00: ps.o 99/04/29

So, is there any other options for me? :frowning:

---------- Post updated 04-23-13 at 09:22 AM ---------- Previous update was 04-22-13 at 02:33 PM ----------

Ermm.. Isn't there a solution for this? :frowning:

Thank you.

From Simple rules of the UNIX.COM forums:

If you cannot extract the information that you need from ps because the kernel does not provide it, then it's time to reconsider the approach.

It may be possible to restrict matches based on uid, gid, or some other attribute, but you have neglected to describe the situation.

Regards,
Alister

Try

UNIX95=1 ps -eo pid,user,time,args

For filtering, pipe this to awk,
for example to

awk '$2=="oracle9" && /CP/'

Thanks..

But using the first code

UNIX95=1 ps -eo pid,user,time,args

, the output still ge truncated:

12609 oracle9     00:03 sqlplus -s /nolog
16660 oracle9     00:00 sh /bistari/dw/iodds1/oradata/load/ICP/SubScript/run_icp_mol
13729 oracle9     00:19 oracleCRISP (LOCAL=NO)
28323 oracle9     00:00 sh /home/oracle9/dba_area/general/exec_proc.sh PROC_ICP_SR_M
 3666 oracle9     00:04 oracleCRISP (LOCAL=NO)
12581 oracle9     00:00 sh /home/oracle9/dba_area/general/exec_proc.sh PROC_ICP_SR_C
28362 oracle9     00:04 oracleCRISP (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))
10350 oracle9  01:37:58 oracleCRISP (LOCAL=NO)

Thank you.