- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Argument Checking
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
Forums
Discussions
Discussions
Discussions
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
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
06-19-2006 02:47 AM
06-19-2006 02:47 AM
proc_jobman=$(UNIX95=l ps -u root -o pid,args|grep /opt/maestro/bin/jobman|awk 'BEGIN {ORS = " "} {print $1}')
if [[ -n $proc_jobman ]]
then
#kill the jobman process
echo "sending kill to jobman process $proc_jobman"
kill -9 $proc_jobman
fi
Thanks in advance,
Chuck Ciesinski
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2006 02:53 AM
06-19-2006 02:53 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2006 02:56 AM
06-19-2006 02:56 AM
Re: Argument Checking
But if its just the pid and args you are interested in then you may also use
ps -u root -f | awk '{print $2,$NF}' ....
Regards,
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2006 03:02 AM
06-19-2006 03:02 AM
Re: Argument Checking
First, release 11.11 is known as 11iv1.
With HP-UX it is necessary to arm the UNIX95 (XPG4) option to be able to use the '-o' switch.
This is in fact the best/safest/easiest way to match a process's basename to 'ps' output and be assured that you find only what you want.
Be setting confining the setting of UNIX95 to the command line for the 'ps' you are keeping the variable set only for the commandline. This is desirable since exporting UNIX95 into your environment may affect other commands in ways you don't want. The 'cp' command is one command that is influenced differently by this setting.
ALSO:
Never kill with 'kill -9' except as a last resort. A 'kill -9' cannot be ignored or trapped and it doesn't give a process any chance to clean up shared memory segments or remove temporary files.
Instead, use a multi-level kill, starting with a hangup; then a simple 'kill -15'; and as a last resort a 'kill -9'.
The following script will kill a process by name in a much safer way:
# cat .killer
#!/usr/bin/sh
myproc=`basename ${1}`
[ -z "${1}" ] && { echo "no process specified!"; exit 1; }
mypid=`UNIX95= ps -C ${myproc} -o pid=`
if [ ! -z "${mypid}" ]; then
kill -1 ${mypid} 2>/dev/null
sleep 3
kill -15 ${mypid} 2>/dev/null
sleep 3
kill -9 ${mypid} 2>/dev/null
fi
exit 0
...Run as ./killer basename
...where 'basename' is the name of the process you want killed.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2006 09:35 AM
06-19-2006 09:35 AM
Re: Argument Checking
alias ps='UNIX95= /usr/bin/ps'
Now you always get the -o (etc) options. As James implied with his scri-pt, get rid of all your ps|grep scripts! grep is a terrible way to locate process names. Just try this to find all the sh processes:
ps -ef|grep sh
If you were to script this and kill the matching processes, you would kill (among other things):
- unhashdaemon and sshd
- all processes owned by josh and sherry
- shells like sh ksh csh bash tcsh
A very bad situation indeed. Always use -C to select a process by it's exact name as in:
UNIX95= ps -fC sh
And another nifty feature: the -o headers for the selected columns can be removed with header= as in:
UNIX95= ps -fC sh -o pid= -o ppid= -o args
By setting all the -o options to a null title, the entire title line disappears, saving an extra test to drop the title line.
Another overlooked feature in ps is the standard (UNIX95 not needed) -u and -p options which find processes by username and PID respectively. So ps is full of 100% accurate selection options. No more grep for ps.
Bill Hassell, sysadmin