All my machines run TCL13.1 x86_64 with Xorg-7.7. My X session and window manager (fluxbox) start automatically on boot on all of them.
On my media player, X crashes once in a while. I'm not sure why, but it would be simpler to create a watchdog-type script that restarts X when it crashes than it would be to troubleshoot.
Here is my x-watchdog script:
#!/bin/sh
log=$HOME/log.txt
while true; do
if pgrep Xorg >/dev/null; then
true
else
echo "Restarting X" >>$log
startx
fi
sleep 10
done
The script is launched at boot as regular user and runs continuously in the background. To test the script, I intentionally stop X by running
pkill Xorg, which causes a virtual terminal to show up as expected. I then wait 10 seconds or more. The log shows "Restarting X" but X does not restart as expected; the startx in the script seems to have no effect
If I manually run
startx at the console, then it works just fine (i.e., X and my WM start as expected).
Why does the
startx in the script have no effect? Does anyone know how to fix the script so that
startx works?