Recycle SQL Agent Error Logs

  • WhiteLotus

    SSChampion

    Points: 11861

    hi all

    I want to keep 1 month worth of SQL agent Error logs and plan to cycle every week  by running : EXEC dbo.sp_cycle_agent_errorlog ( using SQL JOB)

    How do I do this ?

    Thanks All

     

  • Sue_H

    SSC Guru

    Points: 90142

    Create a job with a job step in msdb database that executes the command: Exec dbo.sp_cycle_agent_errorlog

    And then schedule it to run once a week.

    Sue

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 715370

    By default, the agent maintains 9 logs. Each time the service starts, it creates a new log and discards the oldest one.

    If you recycle manually once a week, you should have nine weeks, but any service restart could change this, so you could potentially have less than a month of logs at any time. You can also set to remove history older than xx weeks in the Agent Properties.

     

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply