loserbrewer
asked on
Kill question
Can a wildcard (*), be used with a kill statment?
for example, if you wanted to kill all process starting with 123, could you run kill 123*
or to kill all process, could you type
kill*
thanks
for example, if you wanted to kill all process starting with 123, could you run kill 123*
or to kill all process, could you type
kill*
thanks
if you wand to do similar thing, then you may filter the processes ids (e.g. using grep) then use kill to terminate processes:
for pid in `ps -ef | grep -v -i ppid | awk '{ print $2 }' | grep ^123`
do
kill -9 $pid
done
or
kill -9 `ps -ef | grep -v -i ppid | awk '{ print $2 }' | grep ^123`
for pid in `ps -ef | grep -v -i ppid | awk '{ print $2 }' | grep ^123`
do
kill -9 $pid
done
or
kill -9 `ps -ef | grep -v -i ppid | awk '{ print $2 }' | grep ^123`
What practical purpose do you have for needing this?
If your system has pkill, I'm sure you'd find that a lot more useful.
If your system has pkill, I'm sure you'd find that a lot more useful.
The kill command should be used with utmost caution unless you have the luxury of playing around..All said and done you should always try to kill the process gracefully first with the normal kill command before using the kill -9 which will do a forceful kill.
I also feel as said above...just grep on the process and use a normal kill. If that doesnt work do a forceful kill.
I also feel as said above...just grep on the process and use a normal kill. If that doesnt work do a forceful kill.
ASKER
This was more of a theoretical question. I am just learning UNIX and dont have a system I can work on.
So, does any one think a Kill command will work with a wildcard?
So, does any one think a Kill command will work with a wildcard?
No.
Short answer no. Longer answer, I can't think of any possible practical purpose for this, hence my question about what you wanted to use it for.
pkill is much more useful as it allows you to kill processes based on their name.
pkill is much more useful as it allows you to kill processes based on their name.
ASKER
Thank you for the responses. Anyone know what would happen if you ran kill*, would you get an error or would it look for a process called "*"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can issue a 'killall' command, but I'd becareful issuing it.
Do a 'man killall' for further information on this command.