Thursday, September 15, 2011

Alias to find process id of a running process

This is an example for those who believe in saving time.
You can create your own aliases to save your time from typing long commands again and again.
Create alias
# alias p_id='echo -n '\''process name:'\'';read a;ps -e | grep firefox | cut -d '\'' '\'' -f 2'
Execute it
# p_id
process name:[name of the running process]
[output will be the process id]

2 comments:

  1. Quick fix:

    [me@myboxen ~]# alias p_id='echo -n '\''process name:'\'';read a;ps -e | grep $a | cut -d '\'' '\'' -f 2'

    [me@myboxen ~]# p_id
    process name:httpd
    6818
    6835
    6836
    6837
    6838
    6839
    6840
    6841
    6842


    But why not just use the pidof command?

    [me@myboxen ~]# pidof httpd
    6842 6841 6840 6839 6838 6837 6836 6835 6818

    ReplyDelete
  2. I found your post really helpful. Thanks for posting such informative content. Keep posting.
    joomla extensions

    ReplyDelete