Automatic shutdown if no client is available

- Saturday, May 12, 2007

I have a home file server that shall not run 24/7. So I enabled Wake-On-Lan which was working great. What I missed was some kind of Shutdown-On-Idle. After a little thought I came up with the idea that the server may shutdown when all possible clients are no longer available. So I wrote a little DOS batch script that pings all clients and shuts down the server when there is no one available.

Here's the script:

@echo off

CALL :ping client1
CALL :ping client2

ECHO SHUTTING DOWN IN 30 SECONDS
psshutdown -s -f -t 30
GOTO :EOF

:ping
ECHO Pinging %1 ...
PING -n 1 -w 3000 %1 |find "Reply"
IF errorlevel 1 GOTO :EOF
ECHO %1 is online. Not shutting down...
EXIT

Just save it as a .bat file and schedule it to run every hour or so. I used psshutdown.exe instead of the standard windows shutdown.exe because that one cause an error on my server.

Labels:


0 Comments:

Post a Comment

<< Home