Skip navigation

Rem: Track and Receive Messages About System Uptime

On one of our servers, we have a memory leak that's caused by a problematic application. About every 30 days the server runs out of memory and becomes unresponsive, necessitating an ungraceful shutdown with the On/Off button. We're working with the software vendor to fix the problematic application, but in the interim, what can I do to get a reminder after the server has been up for 21 days?

At my company, we had a server with similar problems. About every 3 weeks, it would slow to a crawl and become unresponsive. The slowdown was due to a backup-client software problem, so there was little we could do but live with the situation until the vendor solved the problem. We knew we shouldn't stretch the uptime beyond 2 weeks, so I used Task Scheduler to run code that sent me a Net Send message when the server was up for 14 days or longer. Here's similar code that will notify you when your server has been up for 21 days or longer:

For /f "tokens=6" %%i in
  ('Uptime MyServer') Do If %%i
  GEQ 21 Net Send
  MyComputer MyServer has
  not been rebooted in %%i days.

In this code, replace MyServer with the name of the server you want to monitor and MyComputer with the name of the computer on which you want to receive the message. This computer must be running the Messenger service for the code to work.

The code uses the Uptime tool to determine the server's uptime. You can download this tool from, or you can find it in the Windows resource kits.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.