baudolino Posted January 21, 2003 Share Posted January 21, 2003 Want to know how to pipe the two commands below. The first one writes the pid of the process mpg123, the second one kills it. $ps -C mpg123 -o pid= 2206 $kill -9 2206 Tried $ps -C mpg123 -o pid= |kill -9 without success. Thanks. baudolino Link to comment Share on other sites More sharing options...
fuzzylizard Posted January 21, 2003 Share Posted January 21, 2003 try this $ pd=`ps -C mpg123 -o pid=` | kill -9 $pd and see if that works. Link to comment Share on other sites More sharing options...
baudolino Posted January 21, 2003 Author Share Posted January 21, 2003 :-( it doesn't Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted January 21, 2003 Share Posted January 21, 2003 Why not just killall -e mpg123 ? Link to comment Share on other sites More sharing options...
aru Posted January 21, 2003 Share Posted January 21, 2003 why piping here? just use the output of your first command as a parameter for the second one: ~$ kill -9 $(ps -C mpg123 -o pid=) or ~$ kill -9 $(/sbin/pidof mpg123) but Steve Scrimpshire is right, the more stright forward way will be using /usr/bin/killall: ~$ killall -e -s SIGKILL mpg123 btw, usually SIGKILL (same as kill -9) is not a good idea since the process killed that way probably won't be able to close itself the right way. Is better to try to kill it with a signal 15 (SIGTERM), and if that doesn't work, then kill it with signal 9. Link to comment Share on other sites More sharing options...
theYinYeti Posted January 21, 2003 Share Posted January 21, 2003 Yes, killall is easier, and try without -9 first. Also the $(ps ...) idea is good. Anyway if you still want to do this with a pipe, this should work: ps -C progname -o pid | xargs kill or ps -C progname -o pid | xargs kill -9 Yves. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now