command line - Kill all the other instances of a running process except the very first one - Ask Ubuntu
i working on project in need mplayer run several instances in order create voice-over-music real-time mixing 2 files. so, music playing @ 90% volume (represented "m" in next timeline) , @ moments lower volume ("m") in order place voice ("v") on music, after we'll return music 90% when voice sample finishes.
timeline (minutes)
0===========1===========2===========3===========4===========... _____________vvvvvvvv__________vvvvvvvvvvvvvv__________vvvvv... mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm... everything working pretty fine far. but, reason, many times second mplayer instance finishes voice-off playback process still remains active , won't ever end.
the answer provided right here: kill processes except 1 running script not working case.
i have tried accepted answer on question: https://unix.stackexchange.com/questions/50555/kill-many-instances-of-a-running-process-with-one-command kill every instance of mplayer , need keep first 1 playing music.
in page http://www.oracleflash.com/20/how-to-kill-all-processes-with-one-command-in-linux.html reproduce way kill processes initiated application. useful case kill instances of mplayer.
expected solution
i saving pid of music player with:
mplayer -shuffle -playlist playlist.m3u </dev/null >/dev/null 2>&1 & echo $! > player.pid with pid number, i'd use last given page's solution in order kill processes except 1 saved in player.pid file. so, placing cat player.pid in middle of
kill -9 `ps -ef | grep oraxpo | grep -v grep | awk '{print $2}' may trick.
the problem don't know place it. or if there different/better way it.
another idea kill last processes 1 @ once stopping on first one.
any ideas appreciated.
thanks in advance.
you can try:
pgrep mplayer | grep -vf player.pid | xargs kill -9 notes:
pgrepthe tool looking process information. supports negating matches , using pid files, unfortunately couldn't figure out way selectively negate matches.- since have file, have
grepread file-f, , negate matches-v xargsconverts input arguments, don't need use command subtitution
Comments
Post a Comment