LearningCpp
LearningCpp

Reputation: 972

Full command not visible using ps in solaris

the command that was run by cronjob

bin/bash /abc/bcd/def/ghi/connectivity/connectivity_script.sh start tof as abcde with abc/abc.prop

But while i try to see this process using

/usr/ucb/ps -auwwwxxxx | egrep "connectivity_script.sh"  | cat

i just see the below , but not the entire command.

bin/bash /abc/bcd/def/ghi/connectivity/connectivity_script.sh start tof as

How to fetch the entire command that was run using ps as i need to know which property file has been used?

abc/abc.prop in this case

Upvotes: 2

Views: 4572

Answers (2)

Danek Duvall
Danek Duvall

Reputation: 377

As Sasha says, pargs is the best (and only, on older versions of Solaris) way to look at a process's entire argument vector, but pgrep is the best way to find the process in the first place. Because the thing you're searching for is not the name of the executable, you'll need the -f argument. Thus:

pgrep -f connectivity_script.sh

Combining with pargs:

pargs $(pgrep -f connectivity_script.sh)

Note that unless you own the process or have elevated privilege, you won't be able to see the entire argument vector of a process, and so the pgrep invocation may fail to find what you're looking for, and pargs definitely won't show it. That limitation is present even in the newer versions of Solaris Andrew mentioned.

Upvotes: 2

Sasha Golikov
Sasha Golikov

Reputation: 738

You may use in Solaris:

pargs -l PID

to get all arguments of process in one line if you know its PID. Also you may get the particular argument of process in such way:

pargs -a PID | grep 'argv\[8\]' | cut -d: -f 2 

Or you may use ps with options if you know only one of process arguments:

/usr/bin/ps -A -o pid,args | grep connectivity_script.sh | grep -v grep

In older Solaris versions ouput of arguments in /usr/bin/ps is limited with 80 chars, so you need two-steps to do: 1) get PID from ps, 2) get full args from pargs.

PID=$(/usr/bin/ps -A -o pid,args | \
      grep connectivity_script.sh | \
      grep -v grep | \
      cut -d" " -f 1 )
pargs -l $PID

Upvotes: 4

Related Questions