Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Keep track of stopped processes via shell variables' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Keep track of stopped processes via shell variables
Authored by: LC on Dec 15, '03 12:32:08PM
To shorten your shell commands, either use brackets e.g.
ps -ax | grep '[k]ext' | awk '{print $1}'
or, in sh/ksh/bash etc. it's easier to set and shift (positionals) ...
but there is --
killall [-d | -v] [-h | -?] [-help] [-l] [-m] [-s] [-u user] [-t tty] [-c procname] [-SIGNAL] [procname ...]
Also, if you started any commands from this shell (term), can just
jobs -l
then
kill %1
bg %2

etc. Larry

[ Reply to This | # ]
Keep track of stopped processes via shell variables
Authored by: LC on Dec 15, '03 12:39:15PM
Also, in a shell wrapper the pid of a launched (bg) command is available -- (csh)
some_command & ; set pid = ${!}
kill ${pid}


(sh)
pid=${!}

Larry.

[ Reply to This | # ]
Keep track of stopped processes via shell variables
Authored by: LC on Dec 15, '03 12:42:31PM
Oh yeah, to make those greps correct (in case there are multiple binaries running with similar names), need to --
ps -ax | grep '[k]ext' | head -1 | awk '{print $1}'
i.e. use head or tail to stuff just the first one into your variable; Larry.

[ Reply to This | # ]