Why won't this script run on startup?
This script works perfectly when I launch it manually. How can I get it to run on startup? The function of the script is to get Docky
to auto relaunch in the case of a crash.
I created the script like this:
gedit ~/process_monitor.sh
Pasted in the following (found it on Ask Ubuntu):
#!/bin/bash
if [[ -z "$1" ]];then
echo "ERROR: must specify program"
exit 1
fi
while (( 0 == 0 ));do
$@ &
pid=`jobs -l | awk '{print $2}'`
wait $pid
done
Saved the file.
-
Set the permission:
chmod a+x ~/process_monitor.sh
Now, when I run it like this, it works perfectly:
~/process_monitor.sh docky
However, when I add the following to startup applications, that does not make the script launch on startup. Well, maybe it does, but the script doesn't work.
/bin/bash ~/process_monitor.sh docky
Basically there's some sort of graphical element that flashes on the screen for half a second, but no other sign of the script to be seen, and Docky
does not relaunch if it's killed.
How to make this work? I'm sure it's extremely basic.
I'm on Ubuntu 14.04.
Solution 1:
Using paths in a .desktop file
The issue is that Startup Applications creates a .desktop
file in ~/.config/autostart
In a .desktop
file, you cannot use relative- or variable paths like ~
. Use absolute paths instead:
/bin/bash /absolute/path/to/process_monitor.sh docky