Free Power Tools Brochure
Get Mark Minasi's
17-page guide today!



      

advertisement

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

January 22, 2002 06:22 PM

Automatically Name Log Files With the Current Date and Time

Rating: (0)
Windows IT Pro
InstantDoc ID #23468

Editor's Note: Share your Windows and .NET discoveries, comments, problems, solutions, and experiences with products and reach out to other Windows & .NET Magazine readers (including Microsoft). Email your contributions (400 words or less) to r2r@winnetmag.com. Please include your phone number. We edit submissions for style, grammar, and length. If we print your submission, you'll get $100. Submissions and listings are available online at http://www.winnetmag.com/articles. Enter the InstantDoc ID number in the InstantDoc ID text box.

When Windows NT Backup writes a log file, the program always uses the same name. This method overwrites previous days' logs and thus leaves administrators wondering whether their backups have been working. To solve this problem, I wrote the script that Listing 1 shows to automatically name log files with the current date and time.

I used ntdate.exe, which is in Jeffrey Harris's freeware AINTX Toolset (available at http://user.mc.net/~jlh/nttools/html/download_aintx.htm), and the form of the for /f command that parses command outputs. Ntdate provides the parsed system date to the for command.

I put the command file in NT's Scheduler. You can use REM statements (i.e., ::) on the line containing the Ntbackup command to specify whether you want full or incremental backups. This script is for NT 4.0 and includes optional lines to accommodate Microsoft Small Business Server (SBS) 4.5.

ARTICLE TOOLS

Add a Comment

I have used the script and it works fine. However the problem is that i get two log files as the output after I execute the script. Oneis empty while the other has the output. Any fix for this bug??

Suraj 2/5/2003 4:48:06 AM


It works great but I only need the day, month, year.
But the string varables do not work, %%M and %%m give both the hour.
What are the exact varaibles to get an output like 250202 (meaning 25th february 2002)?

richard2/25/2002 3:48:51 AM


When I run the batchfile it works fine but I get two logfiles.
One with filename in capitalform and one "normal", only the log-file in capitalformat hold data.

richard2/25/2002 3:48:51 AM


You must log on before posting a comment.

Are you a new visitor? Register Here

Setup rights to helpdesk group to unlock shared files

Does anyone know how to setup a group or permissions for a group (helpdesk) to be able to unlock a shared network file such as a spreadsheet or Access...222-96217

advertisement

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS

Podcasts

To successfully implement virtual desktops, IT administrators must carefully match user requirements to specific desktop technologies. Listen to this podcast to learn what you need to keep in mind when formulating your approach to desktop virtualization.

Downloads

PacketTrap IT is a comprehensive and affordable network management and application monitoring solution that solves problems associated with bandwidth, network and application performance, and connectivity. Gain insight into your network - try PacketTrapIT free for 21 days!

Web Seminars

Aside from its employees, data is an organization’s most important resource. Join Windows technical specialist and 11-time MVP John Savill to learn the best practices for managing data using features in Windows Server.
View this web seminar on demand!

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.