Easy way to redirect the output of a command to both file and terminal:
bash$ my_command 2>&1 | tee my_log.txt
Great =)
Thursday, May 28, 2009
Monday, May 25, 2009
Killing processes started in the current terminal
Imagine you're running some application, lets call it "foo", using an unix user shared with your work colleagues, and this application is also launched by them at the same time you're working. So along the time you may have several instances of this application, several processes with distinct PIDs. And all the sudden you need to kill all the instances that you previously launched but you need to avoid to kill the ones being used by your fellow colleagues. This is one way to do the trick.
Start by retrieving your tty (teletypewriter),
bash$ tty
/dev/pts/4
And then kill the process "foo" for the current "tty" you're using,
bash$ kill `ps -le | grep foo | grep "pts/4" | cut -d" " -f6 `
PS: If know a way to include the retrieval of the tty inside the grep command let know =)
Start by retrieving your tty (teletypewriter),
bash$ tty
/dev/pts/4
And then kill the process "foo" for the current "tty" you're using,
bash$ kill `ps -le | grep foo | grep "pts/4" | cut -d" " -f6 `
PS: If know a way to include the retrieval of the tty inside the grep command let know =)
Subscribe to:
Posts (Atom)