Jazzy Coding

The Art of Structured Improvisation. By Carsten Nielsen

gnome-shell: reload after freeze

Ok, it happened again.

In a nice productive coding session my gnome-shell unexpectedly freezed. The gnome-session got completely unresponsive… or nearly – I was able to switch to another terminal-session.

Using the top command I was able to see that really the gnome-shell-session was eating memory and cpu-time like hell. But how can I send a gnome-shell-reload-command to another terminal-session? No results after a research on the lazy-web… I had to hard-reset my system reset the gdm-windowmanager – nearly loosing all my unsaved code. (Mainly avoided, lucky as I am with a git commit of the cached files in the coding folder – but that’s another story…)

Hmm – what to do then? I need a method to reset the gnome-shell from another session…

I can’t send any commands to another tty (as far as I know). But hey! The sessions are using the same file system!

As a workaround I wrote a small script that runs under the actual gnome-shell-session, checks the existence of a file every 10 seconds and if this file don’t exist simply reloads the gnome-shell-session.

~/.config/gnome-shell-restarter/restarter.sh

#!/bin/bash cd ~/.config/gnome-shell-restarter/

while true ;do
if [ -f delete-to-reload-gnome-shell ] ;then
sleep 10;
else
touch delete-to-reload-gnome-shell;
gnome-shell --replace
fi
done;

As you can see I’ve put the script in the .config folder. I’ve added it to my gnome-autostart by using the “gnome-session-properties” gui-tool.

In case my gnome-shell freezes again, I simply switch to another session with Ctrl-Alt-F1 and delete the “delete-to-reload-gnome-shell” file. Voilá! the gnome-session restarts!

If you have a better solution for this or maybe any hints on gnome-shell, feel free to comment!

Advertisements

12 responses to “gnome-shell: reload after freeze

  1. YuriRC September 28, 2011 at 19:24

    Do you may restart the gdm session from the other tty with “sudo /etc/rc.d/gdm restart” in archlinux or “sudo /etc/init.d/gdm restart” in ubuntu.
    But you will lose all your opened applications.

    Googling i found that killing the gnome-shell with “killall -HUP gnome-shell” makes the gnome restart it again automatically.

    Unfortunately when gnome-shell restarts it freezes again,but a gdm restart makes it work (is faster than a hard-reset).

    I will test your method here too.

    Sorry for any english errors. I’m brazillian and i don’t speak english so much…

  2. phreaknerd September 28, 2011 at 20:55

    Agree, thanks for the hint. A hardreset is normally a “press and hold the power-button” – maybe I should say “hard resetting the window-manager”.
    I tried the killall approach but that just broke the session completely. The shell did’nt restart by itself – maybe because the actual session is focused on another tty? When I use my method after this the shell appears again :-)

  3. YuriRC September 28, 2011 at 21:17

    I actually thought you had done a “sudo reboot” when you talked about “hard reset”. Is the next step for me when I have more serious problems. :)

    I’m using archlinux here, so I don’t know if gnome-shell is restarted in another distributions, but here is the article:
    http://unix.stackexchange.com/questions/13029/how-can-i-automatically-restart-gnome-shell-coming-out-of-suspend-mode

  4. phreaknerd September 28, 2011 at 21:28

    Thanks for the link. The correct command for ubuntu is:

    > sudo killall -s HUP gnome-shell

    I’ll try that when/if the next breakdown appears and check what happens with the cpu/ram.

  5. jag3773 October 18, 2011 at 19:34

    I run into this problem a lot, you’re script looks great!

    Thanks, I’m trying it out.

  6. phreaknerd October 22, 2011 at 17:30

    Nice. Please post your results here!
    I’ll be upgrading to ocelot soon – so hopefully the bug is fixed then ;-)

  7. DesperateSoul December 5, 2011 at 10:15

    Thanks for your usefull script, I will try it ;)

    about what “YuriRC” said, in my case, sometimes gnome-shell does not running. I mean by running “killall” it said “no process found”.
    Maybe I’m wrong in something or somewhere :D

  8. Pingback: Add a simple restart Gnome Shell script to your right-click menu « something I did not know

  9. mb January 28, 2012 at 18:40

    Hey thanks for the little script :)

    I hope your gnome shell stopped freezing, but since mine does (and too often) I posted another solution that might be faster (see the trackback above).

    Cheers!

  10. Eduardo Moya May 1, 2013 at 20:17

    Thank you very much…

    My problem is the same, and for me was also worst, because i was working with virtual machines and everything goes to hell…. literally, now with this workaround you have save me to be worried about this specific issue.

    Ubuntu 12.04 Amd 64 – GNOME Shell 3.4.1

  11. search engine optimization December 17, 2013 at 16:58

    It’s actually a great and useful piece of information. I’m glad that you shared this useful
    information with us. Please stay us up to date
    like this. Thank you for sharing.

  12. Terry September 29, 2016 at 00:37

    killall -s HUP gnome-shell

    worked for me on CentOS 7. Thanks for the tip!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: