For a misbehaving service like that, I'd create a small script that checks if it's running and starts it if it isn't. Then I'd use scheduled tasks to run the script every 5 minutes or so.
Example script (checks for the spooler service):
@echo off
Rem Look for the Print Spooler service in the list of started services
net start | find /i "Print Spooler"
Rem if not found, start it and a restart occurred.
if "%errorlevel%"=="1" (
echo Service "Print Spooler" restarted at %time% on %date% by Script %0>>c:\ServiceRestart.Log
net start "Print Spooler"
)
I feel silly, should've investigated more. Here is the answer just incase I mess this up or anyone else has the same problem. Also, many thanks to @Fiisch for advice and pointing me in the right direction.
When starting fancontrol via #service fancontrol start
or #fancontrol
, the errors of /usr/sbin/fancontrol are not printed. Due to motherboard limitations, my sensors are defined as absolute paths. So I ran /usr/sbin/fancontrol. This causes the error
Configuration is too old, please run pwmconfig again
So I decided to take a look at /usr/sbin/fancontrol to see why. I found the cause at lines 302-307:
# Check for configuration change
if [ -z "$DEVPATH" -o -z "$DEVNAME" ]
then
echo "Configuration is too old, please run pwmconfig again" >&2
exit 1
fi
Its just a simple configuration change detector! since, I had specified the absolute paths for my sensors, not only was this not necessary, it was actually causing the error. So I just commented it out.
## Check for configuration change
#if [ -z "$DEVPATH" -o -z "$DEVNAME" ]
#then
# echo "Configuration is too old, please run pwmconfig again" >&2
# exit 1
#fi
That was it! fancontrol works perfectly now and starts at boot time.
Best Answer
It is easy to get a Windows Service to run a program when it fails. Go to the
Services
snap-in, find the service, double click, and go to theRecovery
tab. There you can choose what happens when it fails.One of the options is
Run a Program
. You can write a script or program that sends an email, and simply point this at it. An easy way is to use Windows'wscript
. See link.