Comment 9 for bug 299361

Revision history for this message
Michael Garabedian (mikegarabedian42) wrote :

I had the same problem. Reinstalling would fix it, but just for a day or two.

I went through and wrote a script that seemed to work in restarting preload.

This script checks for errors in the preload log, saves the state and log file as an backed up log, and then reinitiates the preload. Which seems to work. It fails maybe once a week, but once the state file is rebuilt, everything operates pretty smoothly.

Put this script in /usr/local/bin, chmod +x it, and then add it to the startup applications, browse to the file and set it.
The notify-send and logger commands, will display an image on the script running so you can check it, and the logger commands will drop it in the syslog for you.

#!/bin/bash
now=$(date +"%m_%d_%Y_%H_%M")
if grep 'invalid syntax\|duplicate index\|failed' /var/log/preload.log;
        then
        service preload stop
        cp /var/log/preload.log /var/log/preload.log.$now
        cp /var/lib/preload/preload.state /var/lib/preload/preload.state.$now
        rm /var/lib/preload/preload.state
        rm /var/log/preload.log
        touch /var/lib/preload/preload.state
        touch /var/log/preload.log
        service preload start
        logger -p local0.notice -t PRELOADCHECK "There was a problem with preload, reset"
        notify-send "PRELOADCHECKER" "There was a problem with preload, it has been reset" -i /usr/share/icons/gnome/256x256/status/error.png -t 5000;
else
        logger -p local0.notice -t PRELOADCHECK "Preload has started successfully"
        notify-send "PRELOADCHECKER" "Preload has started successfully" -i /usr/share/icons/gnome/256x256/status/starred.png -t 5000
        exit 0;
fi