- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Killing processes automatically.
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
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
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
тАО09-19-2005 01:52 AM
тАО09-19-2005 01:52 AM
i use the command
"kill -9 `ps -e |grep weblogic.server |cut -c 3-6`"
But there is chance that the number of digits in the pid may increase and than the script will not work.
Please help
Santosh jha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2005 01:58 AM
тАО09-19-2005 01:58 AM
SolutionAutomatically killing processes is generally a bad idea. If, for some reason, your script identifies process 1, for instance, your system is history.
That being said:
ps -ef | grep [w]eblogic_serve | awk '{print $2}' | xargs -i kill {}
is the syntax I'd use if I wanted to do something as dangerous...
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2005 01:59 AM
тАО09-19-2005 01:59 AM
Re: Killing processes automatically.
"kill -9 `ps -e |grep weblogic.server | awk '{ print $2 }'`"
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2005 02:02 AM
тАО09-19-2005 02:02 AM
Re: Killing processes automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2005 02:04 AM
тАО09-19-2005 02:04 AM
Re: Killing processes automatically.
Usage:
killall
Example:
killall weblogic
---------------------
#!/usr/bin/sh
PS=/usr/bin/ps
AWK=/usr/bin/awk
GREP=/usr/bin/grep
KILL=/usr/bin/kill
if [ $# -ne 1 ]
then
echo Kullanim : ./killall proses_adi
exit
fi
for pid in `$PS -e | $GREP $1 | $GREP -v grep | $AWK ' { print $1 }'`
do
$KILL -9 $pid
echo $pid $1 killed
done
-------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2005 02:05 AM
тАО09-19-2005 02:05 AM
Re: Killing processes automatically.
kill -18 is better or just the default (15)...
What I used to do for example - on zombies:
logfile=/tmp/killzombies.log
if [ -f $logfile ];
then
rm $logfile
touch $logfile
else
touch $logfile
fi
Rgds...Geoff
for i in `ps -el|grep -v SZ|grep Z|awk '{print $5}'`
do
ps -ef|grep -v grep|grep ${i} >>$logfile 2>&1
mailx -s "Check Zombie(s)" me@mydomain.com <$logfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2005 02:36 AM
тАО09-19-2005 02:36 AM
Re: Killing processes automatically.
The secon d is ps and grep--a deadly combination. grep doesn't care what it finds on the ps line. The string "weblogic.server" will appear is the ps listing as part of the grep string or it may appear as a parameter given to some program. A worse case is where you grep for weblogic and there are users with that username, there are programs like weblogic.control, etc, all will be found and blindly killed by such a script.
Now true, you are using ps -e rather than -ef which drops the command line arguments, but it is always recommeded to use ps to locate your process by name, not grep. To show you how bad this can be, try these two commands:
ps -ef | grep sh
UNIX95= ps -C sh
The first will find critical system processes like unhashdaemon (don't kill that one!) while the second only find sh (and not ksh or csh, etc)
Here is a general method where the program name is assigned to a variable, and it exactly located with ps -C (note that -c -H and -o are enhanced ps commands and need the UNIX95 variable temporarily set to activate these options)
#!/usr/bin/sh
set -u
export PATH=/usr/bin
PROGNAME=sleep
PROGLIST=$(UNIX95= ps -C $PROGNAME -o pid=)
if [ "$PROGLIST" = "" ]
then
echo "\n$PROGNAME not running\n"
exit 1
fi
for PIDNUM in $PROGLIST
do
echo "\nKilling PID $PIDNUM:"
ps -fp $PIDNUM
kill -15 $PIDNUM
sleep 1
ps -fp $PIDNUM > /dev/null
if [ $? -eq 0 ]
then
kill -1 $PIDNUM
sleep 1
ps -fp $PIDNUM > /dev/null
if [ $? -eq 0 ]
then
kill -9 $PIDNUM
sleep 1
echo "(kill -9 $PIDNUM required)
ps -fp $PIDNUM > /dev/null
if [ $? -eq 0 ]
then
echo "\nWARNING: $PIDNUM cannot be killed\n"
fi
fi
fi
done
Now in this example, I've set PROGNAME to "sleep" so you can test it. It will handle zero or more copies of the same program name, first trying to terminate with SIGTERM (-15), then SIGHUP (-1) and finally SIGKILL (-9) with a warning. And if the process is still not dead, it is hung on I/O and can never be killed.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2005 02:41 AM
тАО09-19-2005 02:41 AM
Re: Killing processes automatically.
echo "(kill -9 $PIDNUM required)
is missing " at the end, should look like this:
echo "(kill -9 $PIDNUM required)"
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2005 08:44 PM
тАО09-19-2005 08:44 PM
Re: Killing processes automatically.
Santosh Jha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2005 05:49 AM
тАО09-20-2005 05:49 AM
Re: Killing processes automatically.
Try
fuser -k programname
If Weblogic as startup script use the traditional shutdown and startup
/sbin/init.d/weblogic restart
or
/sbin/init.d/weblogic stop
/sbin/init.d/weblogic start
Rory