SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How can I leave only only 10 days of SQl Server logs in sql server?‌‌


How can I leave only only 10 days of SQl Server logs in sql server?‌‌

Author
Message
almirfiorio
almirfiorio
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 39
Dear Fiends

inside "Management> SQL Server Logs" I want to automatically delete old logs

How can I leave only only 10 days of SQl Server logs in sql server?

Thanks
Almir
Sue_H
Sue_H
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41719 Visits: 11549
almirfiorio - Thursday, March 1, 2018 1:18 PM
Dear Fiends

inside "Management> SQL Server Logs" I want to automatically delete old logs

How can I leave only only 10 days of SQl Server logs in sql server?

Thanks
Almir


Right click on the SQLServer Logs folder and select configure. You can set the number of logs in that window that comes up.

Sue



Michael L John
Michael L John
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15041 Visits: 9413
Do you want 10 DAYS, or 10 log files?
If you are recycling the logs on a nightly basis, then going into settings is the way to do it as Sue_H suggested.
If you are not recycling the logs, then you may need to implement that as well as what Sue said.

Michael L John
If you assassinate a DBA, would you pull a trigger?
To properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
almirfiorio
almirfiorio
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 39
Michael L John - Thursday, March 1, 2018 1:51 PM
Do you want 10 DAYS, or 10 log files?
If you are recycling the logs on a nightly basis, then going into settings is the way to do it as Sue_H suggested.
If you are not recycling the logs, then you may need to implement that as well as what Sue said.

im want only 10 days of log

Sue_H
Sue_H
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41719 Visits: 11549
almirfiorio - Thursday, March 1, 2018 2:27 PM
Michael L John - Thursday, March 1, 2018 1:51 PM
Do you want 10 DAYS, or 10 log files?
If you are recycling the logs on a nightly basis, then going into settings is the way to do it as Sue_H suggested.
If you are not recycling the logs, then you may need to implement that as well as what Sue said.

im want only 10 days of log


So as Michael and I are both getting at is you can:
Daily you can execute sp_cycle_errorlog. You can create a job to do this at midnight (or whatever time) every day so the log is cycled every day.
And then set max files to 10.

Sue



almirfiorio
almirfiorio
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 39
Sue_H - Thursday, March 1, 2018 2:32 PM
almirfiorio - Thursday, March 1, 2018 2:27 PM
Michael L John - Thursday, March 1, 2018 1:51 PM
Do you want 10 DAYS, or 10 log files?
If you are recycling the logs on a nightly basis, then going into settings is the way to do it as Sue_H suggested.
If you are not recycling the logs, then you may need to implement that as well as what Sue said.

im want only 10 days of log


So as Michael and I are both getting at is you can:
Daily you can execute sp_cycle_errorlog. You can create a job to do this at midnight (or whatever time) every day so the log is cycled every day.
And then set max files to 10.

Sue

Great

you have this jobs?

im want to keep 10 days of all logs (swl server log)

this job keep only error logs ?

Thanks
Almir

Sue_H
Sue_H
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41719 Visits: 11549
almirfiorio - Thursday, March 1, 2018 3:15 PM
Sue_H - Thursday, March 1, 2018 2:32 PM
almirfiorio - Thursday, March 1, 2018 2:27 PM
Michael L John - Thursday, March 1, 2018 1:51 PM
Do you want 10 DAYS, or 10 log files?
If you are recycling the logs on a nightly basis, then going into settings is the way to do it as Sue_H suggested.
If you are not recycling the logs, then you may need to implement that as well as what Sue said.

im want only 10 days of log


So as Michael and I are both getting at is you can:
Daily you can execute sp_cycle_errorlog. You can create a job to do this at midnight (or whatever time) every day so the log is cycled every day.
And then set max files to 10.

Sue

Great

you have this jobs?

im want to keep 10 days of all logs (swl server log)

this job keep only error logs ?

Thanks
Almir


The job would cycle the error logs which means just create a new one. And then when you right click on the SQL Server Logs folder select Configure and set it to 10, it will automatically delete the logs and will just keep 10 of them. So if you cycle the log every day, that would leave a log for every day and you would have 10 logs. So 10 days.
To create the job, just create a new job and it's just one t-sql step of:
sp_cycle_errorlog

Sue



almirfiorio
almirfiorio
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 39
Sue_H - Thursday, March 1, 2018 4:14 PM
almirfiorio - Thursday, March 1, 2018 3:15 PM
Sue_H - Thursday, March 1, 2018 2:32 PM
almirfiorio - Thursday, March 1, 2018 2:27 PM
Michael L John - Thursday, March 1, 2018 1:51 PM
Do you want 10 DAYS, or 10 log files?
If you are recycling the logs on a nightly basis, then going into settings is the way to do it as Sue_H suggested.
If you are not recycling the logs, then you may need to implement that as well as what Sue said.

im want only 10 days of log


So as Michael and I are both getting at is you can:
Daily you can execute sp_cycle_errorlog. You can create a job to do this at midnight (or whatever time) every day so the log is cycled every day.
And then set max files to 10.

Sue

Great

you have this jobs?

im want to keep 10 days of all logs (swl server log)

this job keep only error logs ?

Thanks
Almir


The job would cycle the error logs which means just create a new one. And then when you right click on the SQL Server Logs folder select Configure and set it to 10, it will automatically delete the logs and will just keep 10 of them. So if you cycle the log every day, that would leave a log for every day and you would have 10 logs. So 10 days.
To create the job, just create a new job and it's just one t-sql step of:
sp_cycle_errorlog

Sue

Great

but im want only last 10 days , (not 10 files)

im can keep only last 10 days ?

Thomas Rushton
Thomas Rushton
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: Moderators
Points: 13823 Visits: 7042
If you follow the steps to create a scheduled task to cycle the error log every day, and then set SQL Server to retain only ten logs, then that'll give you your ten days of logs.

Unfortunately, if you reboot the server, that'll also run sp_cycle_errorlog, so you might want to set the number of logs to 11. <insert Spinal Tap reference here>
almirfiorio
almirfiorio
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 39
ThomasRushton - Friday, March 2, 2018 6:01 AM
If you follow the steps to create a scheduled task to cycle the error log every day, and then set SQL Server to retain only ten logs, then that'll give you your ten days of logs.

Unfortunately, if you reboot the server, that'll also run sp_cycle_errorlog, so you might want to set the number of logs to 11. <insert Spinal Tap reference here>

When reboot the server the jobs cannot continue ? im need to setg to 10 again? why ?

Thanks
Almir

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search