My name is Philipp C. Heckel and I write about nerdy things.
This site moved here recently from blog.philippheckel.com!

Snippet 0x07: Restart Docky from a cronjob (when it crashed)


Code Snippets, Scripting

Snippet 0x07: Restart Docky from a cronjob (when it crashed)


I recently updated from Linux Mint 16 Petra to Linux Mint 17 Qiana. Everything went smoothly, except for my dock Docky. For some reason, Docky decides to crash every once in a while with some error message.

Instead of fixing this error or reporting it, I decided to find the easy way out and simple set up a cronjob to restart Docky every minute (if it has crashed).

Because it took me a bit (and you might have trouble with it too), this tiny post shows you how to do that. Simply add this to your crontab to let cron run this command every minute. Open the crontab via crontab -e:

This command solves a few issues:

  • It checks if Docky is already running by ps-ing and grep-ing for the Docky.exe process. The X? prevents the grep from showing up in the results.
  • If Docky isn’t running, it sets the DISPLAY variable to the first display (:0.0 in most cases).
  • It launches Docky via dbus-launch docky, because Docky requires dbus to run.

That’s all the magic. Works like a charm for me.

Leave a comment

I'd very much like to hear what you think of this post. Feel free to leave a comment. I usually respond within a day or two, sometimes even faster. I will not share or publish your e-mail address anywhere.