- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to find specific username and command ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 06:21 AM
тАО12-30-2010 06:21 AM
Solved! Go to Solution.
- Tags:
- PS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 06:29 AM
тАО12-30-2010 06:29 AM
Re: script to find specific username and command hpux 11.23
UNIX95= ps -C(cmdlist) -U(uidlist)
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 06:36 AM
тАО12-30-2010 06:36 AM
Re: script to find specific username and command hpux 11.23
You could use 'ps' under the 'UNIX95' (or XPG4) behavior like this:
# UNIX95= ps -C oracleLCCC -o pid= -o user= | grep oracle
This finds all processes with a basename of "oracleLCCC" and lists (sithout headings) their 'pid' and effective login name ('user').
Note the white space after 'UNIX95='. This causes the variable to be set only for the duration of the command line.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 06:58 AM
тАО12-30-2010 06:58 AM
SolutionFor your example, the process oracleLCCC is probably run only by the oracle user so this command is sufficient:
UNIX95=1 ps -C oracleLCCC
The command:
UNIX95=1 ps -U oracle
will find all processes owned by the user oracle. Using the UNIX95=1 variable and the extended options (man ps) will eliminate the mistakes made when combining ps and grep together.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 07:07 AM
тАО12-30-2010 07:07 AM
Re: script to find specific username and command hpux 11.23
We had a lively discussion about how best to arm the UNIX95 behavior here:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1276190
You can note that any of the following will *set* the behavior:
# UNIX95=
#UNIX95=1
# UNIX95=EXTENDED_PS_FEATURES
#UNIX95=0
The last line suggests that 'UNIX95=0' might turn off the XPG (UNIX95) behavior. This is *NOT* true. The action 'UNIX95= ' or 'UNIX95=0' or 'UNIX95=1' equally result in an defined value which toggles the XPG behavior. Simply compare:
# UNIX95= ps -C sh
# UNIX95=0 ps -C sh
# UNIX95=1 ps -c sh
...and you will see no difference.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 09:23 AM
тАО12-30-2010 09:23 AM
Re: script to find specific username and command hpux 11.23
UNIX95= ps -C oracleLCCC -o pid= -o user= | grep oracle >> nothing
UNIX95=1 ps -C oracleLCCC >>> # UNIX95=1 ps -C oracleLCCC
PID TTY TIME CMD
UNIX95=1 ps -U oracle >> listad all processes owned by oracle
is there some reason the
UNIX95= ps -C oracleLCCC -o pid= -o user= | grep oracle command doesn't return anything ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 09:54 AM
тАО12-30-2010 09:54 AM
Re: script to find specific username and command hpux 11.23
> is there some reason the
UNIX95= ps -C oracleLCCC -o pid= -o user= | grep oracle command doesn't return anything ??
The '-C oracleLCCC' assumes that the *basename* of the command is "oracleLCCC". If by "command" you meant somewhere in the whole command line, match this, then you might do something like:
# UNIX95= ps -e -opid= -ocomm= -ouser= | awk '$2~/oracleLCCC/ && $3~/oracle/'
If the token "oracleLCCC" is an argument to a process of another basename, use:
# UNIX95= ps -e -opid= -oargs = -ouser= | awk '$2~/oracleLCCC/ && $3~/oracle/'
By the way, when you get to 11.31 have a look at 'pgrep(1)' :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 10:04 AM
тАО12-30-2010 10:04 AM
Re: script to find specific username and command hpux 11.23
Since grep doesn't care whether the string is oracle or oracleLCCC, this would indicate that there is no process by the name "oracleLCCC". Spelling counts in the -C option. Do this instead:
UNIX95= ps -U oracle -opid= -o user= -o comm=
Now you will see all the processes by name that are owned by oracle. Change -o comm= to -o args= and you'll see the command line.
The -C is an exact match for the process name -- no pathnames, no arguments, etc. To see if there is anything like LCCC, do this:
UNIX95= ps -U oracle -opid= -o user= -o args= | grep -i LCCC
There may be a special character in the process name (yuk) so if you see the process with -U oracle but grep can't find it, pipe the output to cat -tv and look for garbage characters:
UNIX95= ps -U oracle -opid= -o user= -o comm= | vis
And just to clarify, UNIX95 is a temporary variable whose contents is unimportant. That's why UNIX95= (which is null) and UNIX95=0 (which has a value) produces the same result. As long as UNIX95 has a value, ps will enable the extended options.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2010 12:41 PM
тАО12-30-2010 12:41 PM
Re: script to find specific username and command hpux 11.23
UNIX95=EXTENDED_PS ps -H -fu oracle