A lot of times, I want to see what the task number is of a running task. I might want to see if there are multiple occurrences of a task, or a zombie task (defunct).
Easy way is to:
ps -ef | grep taskname
ps says give me a snapsnot of all the running tasks. The -ef says give me all the tasks, and give me a full listing. That is then piped (that is the output of ps, becomes the input to grep and we are searching for some task name.
But that get’s tiresome.
Easier way? Sure!
Add an alias to .bash_aliases!
alias thog='ps -ef | grep $1'
So use your favourite editor, add the line above, then exit.
NOTE: IN ORDER FOR CHANGES TO BE READ, YOU MUST LOGOUT/BACK IN.
So we created a command called “thog” (could be anything as long as it doesn’t conflict with any installed programme) — and I pass the command line argument $1 to it. (The first command line argument)
So the output would look like this:
nwayno@Homer:~$ thog java
root 2031 1 0 Oct28 ? 00:13:16 java -Xmx100m -Dsubsonic.home=/var/subsonic -Dsubsonic.host=0.0.0.0 -Dsubsonic.port=4040 -Dsubsonic.httpsPort=0 -Dsubsonic.contextPath=/ -Dsubsonic.defaultMusicFolder=/var/music -Dsubsonic.defaultPodcastFolder=/var/music/Podcast -Dsubsonic.defaultPlaylistFolder=/var/playlists -Djava.awt.headless=true -verbose:gc -jar subsonic-booter-jar-with-dependencies.jar
nwayno 28470 28430 0 21:07 pts/0 00:00:00 grep java
That shows me the java (or whatever) task number. Might be useful if you want to kill a task.
Want to see all the Zombie tasks? (tasks that have no parent task)
nwayno@Homer:~$ thog defunct
root 28843 2067 1 21:11 ? 00:00:00 [miniserv.pl]
nwayno 28852 28430 0 21:11 pts/0 00:00:00 grep defunct
So now you know.
By the way, I corrected the spelling of Adventures in the title. Taking it a bit easy this week, still healing.
enjoy,
Wayno