Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Rotate Scheduled Task log file

Posted on 2006-11-24
8
Medium Priority
?
571 Views
Last Modified: 2012-05-05
Is there a way to rotate/archive the scheduled task log file?
0
Comment
Question by:John Tolmachoff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18009407
I presume you mean the SchedLgU.Txt file in windows directory?  If so it does rotate around afaik keeping around 32k in size, as in it overwrites itself leaving a line such as this in the file :

[ ***** Most recent entry is above this line ***** ]

Nothing stopping you creating a batch file which copies this somewhere else then scheduling it, e.g. schedule a job to run once a day, week or month which runs a batch file something like this:

@echo off
REM Copy schedule log to fil e
mkdir C:\sch-logs 2>NUL
net stop "task scheduler"
copy "%windir%\schedlgu.txt" "c:\sch-logs\%date:/=-%.txt"
del "%windir%\schedlgu.txt"
net start "task scheduler"

0
 
LVL 1

Author Comment

by:John Tolmachoff
ID: 18009961
But how can you stop the "Task Schedule" service when you are running a job that is called by it?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18009993
Haven't tried it but by the time the job is started it should be a separate task in memory and continue... will have a check over the weekend if I get a chance.
You could always run the job on another server under its task scjeduler and use sc.exe to stop the service on the other box and access the log file using the unc path...

What are you after here?
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 1

Author Comment

by:John Tolmachoff
ID: 18010001
I have a number of tasks that run multiple times per day which quickly overwrite task log lines more than 12 hours old. I would like to be able to review say 10 days worth of logs.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18010061
Ok, well you can certainly copy the logs without stopping the scheduler as long as it doesn't get deleted ... late now will check back tomorrow.
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 375 total points
ID: 18015516
Ok, using the batch file above I was able to have it stop the task scheduler from a scheduled job itself, copy and delete the log file and restart the scheduler.  Another scheduled job that had already been started continued running fine while the scheduler restarted as expected.  I adjusted the batch file so that it appends the log file each time it is run to the end of the current day's log archive. The second part of the batch file then removes all but the most recent 10 files in that directory.

let me know if any of that needs explanation etc.

Steve

@echo off
REM Copy schedule log to file
mkdir C:\sch-logs 2>NUL
net stop "task scheduler"
copy "c:\sch-logs\%date:/=-%.txt"+"%windir%\schedlgu.txt" "c:\sch-logs\%date:/=-%.txt"
del "%windir%\schedlgu.txt"
net start "task scheduler"

REM Remove all but last ten log files:
for /f "skip=10 tokens=*" %%a in ('dir C:\sch-logs\*.txt /o-d /b') do echo del "c:\sch-logs\%%a"
0
 
LVL 1

Author Comment

by:John Tolmachoff
ID: 18017419
I like it, thanks, that will work.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18017774
Glad you liked it, not keen on getting a B grade, especially on 125 points for a custom solution mind...

Steve
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question