Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


February 2002

Automatically Name Log Files With the Current Date and Time

RSS
Subscribe to Windows IT Pro | See More Backup and Recovery Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

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.

End of Article



Reader Comments
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)?

Richard February 25, 2002


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.

Richard February 25, 2002


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 February 05, 2003


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
PsExec

This freeware utility lets you execute processes on a remote system and redirect output to the local system. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

How can I stop and start services from the command line?

...


Storage Whitepapers Combining Deduplication and VMware Disaster Recovery: Cascading Savings Improves Cost Effectiveness

Virtualizing Microsoft Exchange Server 2007

StoreVault SnapManagers for Microsoft Exchange and SQL Server

Related Events Storage Consolidation for Your Microsoft Applications: Reducing Cost and Complexity

Virtualization, Automation and Databases

Virtualization Management

Check out our list of Free Email Newsletters!

Storage eBooks A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Keeping Your Business Safe from Attack: Encryption and Certificate Services

Related Storage Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing