none
Rotate File with Date Stamp and Zip RRS feed

  • Question

  • Hey Guys

    New to powershell.. Just want to write a simple script to do the following. The file is called D:\test.log

    1) Rotate it every night at 12pm (I guess schedule via task manager)

    2) Rename it to YYYY-MM-DD-filename.log at that time. Create a new file called test.log so current logging can continue (or just keeps running on that file after rename of file)

    3) Zip it. and leave it there..

    Can anyone help on how to do so? And also if I want to expand this script to do multiple files (but same rotated file format), that would be helpful (I guess some for each statement ? )

    Will run on Windows 2008 R2 Servers..

    Appreciate your help!!!

    Sunday, July 27, 2014 10:51 PM

Answers

  • Hi FIM,

    as Bill and jrv already did, I too recommend learning to do this yourself. Your own skills will never desert you after all :)

    That said, for this issue there's already a nice solution that might work for you, called logrotatewin.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Monday, July 28, 2014 6:36 AM

All replies