I am on Ubuntu GNOME 15.10 with GNOME 3.18, but I don't like the normal applications launcher so I have installed Docky, however often Docky suddenly closes and I am forced to manually restart it, so I was wondering how I could make a daemon which runs all the time in the background that would check at regular intervals if Docky is running, and if it is not, run it?
Asked
Active
Viewed 96 times
1 Answers
1
Create a script anywhere you want it to be, preferably in your home directory. I like to call mine, check_docky.bsh. In your script, do the following lines:
#!/bin/bash
ps -ef | grep -i docky.exe | grep -v grep >/dev/null
case $? in
1) sh -c "mono /usr/lib/docky/Docky.exe";;
0) exit 0;;
esac
In the above script, the ps -ef | grep will look to see if Docky is running. If it is not running the exit code that gets returned is 1, so then the case statement would relaunch Docky automatically. Else, the script would exit normally with a code 0.
Make sure the script is executable:
chmod +x check_docky.bsh
Then create a cron job for the script.
First, run crontab as you:
$ crontab -e
Then as a new entry add the following so that it will check every 10 minutes starting at :00 of the hour:
# m h dom mon dow command
*/10 * * * * /home/<username>/check_docky.bsh
To show that this command works:
~$ ps -ef | grep wookie | grep -v grep
~$ echo $?
1
~$ ps -ef | grep wookie
terrance 20978 6976 0 13:53 pts/17 00:00:00 grep --color=auto wookie
~$ echo $?
0
Hope this helps!
Terrance
- 43,712