CA Client Automation

 View Only
  • 1.  clear server log using script in itcm

    Posted Dec 23, 2016 03:37 AM

    how to clear the server logs (last two days) using client automation(itcm).is there any scripts available please share.



  • 2.  Re: clear server log using script in itcm
    Best Answer

    Broadcom Employee
    Posted Dec 27, 2016 11:04 AM

    If you mean the windows event logs.  You have 2 options.

    1 would be to specify event retention on the logs themselves so they will only keep 2 days worth the other would be to run a script something like this

     

    $Date = (Get-Date).AddDays(-2)

    $Events = Get-WinEvent -FilterHashTable @{ LogName = "Microsoft-Windows-Diagnostics-Performance/Operational"; StartTime = $Date

     

    The above will get ther last 2 days worth of entries.  Then run wevtutil cl to clear the event log.

     

    You need to specify the log name in both cases

     

    This can then be run as an asset job automatically but you would be much better served by just setting the log retention to 48 hours or if you want to do it as a job use the windows scheduler.  There is no sense in using an ax when a knife can do the job.

     

    If you want to do it ad hock then you can do it as an asset job or an sd job.

     

    Richard Lechner

    Principal Engineering Services Architect

     

    CA Technologies

    Mobile: +1 703 655 7161 | Richard.Lechner@ca.com

     

    <mailto:Richard.Lechner@ca.com>[CA]<http://www.ca.com/us/default.aspx>[Twitter]<http://twitter.com/CAInc>[Slideshare]<http://www.slideshare.net/cainc>[Facebook]<https://www.facebook.com/CATechnologies>[YouTube]<http://www.youtube.com/user/catechnologies>[LinkedIn]<http://www.linkedin.com/company/1372?goback=.cps_1244823420724_1>[Google]<https://plus.google.com/CATechnologies>[Google+]<http://www.ca.com/us/rss.aspx?intcmp=footernav>