unix - Kill and restart multiple processes that fit a certain pattern -
I am trying to write a shell script which will kill all the processes that match a certain pattern, then Restart them I can display this process with them:
ps -ef | Grep ws_sched_600.sh | Grep -v grep | Sort -k 10
The list provides relayer processes:
User 2220258 1 0 16:53:12 - 0:01 / bin / KSH /../../../../../ws_sched_600 Sh EDW02_env User 5562418 1 0 16:54:55 - 0:01 / bin / KSH /../../../../ Ws_sched_600.sh EDW03_env User 2916598 1 0 16:55:00 - 0: 01 / bin / ksh /../../../../../ws_sched_600.sh EDW04_env
< P> But I'm not sure how to kill the pass of the process ID?
sort
does not seem necessary to you command-line arguments to the
, you can use awk
to print the other columns and xargs
. .
ps -ef | Grep ws_sched_600.sh | Awk '{print $ 2}' | | Xargs kill
Alternatively, you can use pkill
or killall
, which kicks on the basis of process name:
Pkill -f ws_sched_600.sh
Comments
Post a Comment