Monday, April 16, 2012

Restarting specific process id

Several times a day gnome-shell will crash and need to be restarted, normally I go into a virtual console and type:
ps -ef | grep gnome-shell
and see results like:
mdeimel 23496 2008 14 09:43 ? 00:00:01 /usr/bin/gnome-shell
mdeimel 23509 1 0 09:43 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server
mdeimel 23522 20953 0 09:43 pts/1 00:00:00 grep --color=auto -i gnome-shell
then I type:
kill -1 23496
in order to kill and restart the service (the '-1' parameter calls a restart of the same process)

In an attempt to speed-up this process I created an alias to handle everything at once. Instead of using the "ps" command I started using "pidof" to get the exact process id right away, and pass that into the kill command:
kill -1 `pidof gnome-shell`
and to save as an alias in ~/.bashrc I have
#Restart gnome
alias gnome="kill -1 `pidof gnome-shell`"

No comments:

Post a Comment