The CBS.log
in C:\Windows\Logs\CBS\
is generated by the Component Based Servicing (CBS) system which handles Windows updates and component installations. Under normal circumstances, Windows should automatically:
1. Rotate logs when they reach ~50MB 2. Create compressed CAB archives (CbsPersist_yyyymmddtttttt.cab) 3. Maintain only recent log files
Several factors can prevent automatic log rotation:
- Pending updates: If updates are stuck in pending state
- Permission issues: SYSTEM account needs full control
- Service disabled: Windows Modules Installer service
- Registry settings: Compression thresholds modified
You can manually manage these files:
# PowerShell command to safely clean old logs Get-ChildItem "C:\Windows\Logs\CBS\" -Filter "CbsPersist_*.cab" | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} | Remove-Item -Force # For active CBS.log (requires stopping services) Stop-Service -Name TrustedInstaller -Force Remove-Item "C:\Windows\Logs\CBS\CBS.log" -Force Start-Service -Name TrustedInstaller
Create a scheduled task with this PowerShell script:
$logPath = "C:\Windows\Logs\CBS\" $maxSize = 50MB $logFile = Join-Path $logPath "CBS.log" if ((Get-Item $logFile).Length -gt $maxSize) { Stop-Service -Name TrustedInstaller -Force $timestamp = Get-Date -Format "yyyyMMddHHmmss" $archiveName = "CbsPersist_$timestamp.cab" makecab $logFile (Join-Path $logPath $archiveName) Remove-Item $logFile Start-Service -Name TrustedInstaller }
Check for underlying issues causing log growth:
# Check for pending updates dism /online /cleanup-image /analyzecomponentstore # Verify CBS registry settings Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing"
During routine disk space audits on our Windows Server 2008 R2 infrastructure, we discovered several instances where C:\Windows\Logs\CBS\CBS.log
files grew excessively large (some reaching ~1.5GB). This immediately raised two key questions:
- Why aren't these files being automatically compressed into
CbsPersist_yyyymmddtttttt.cab
archives as expected? - What's the safest approach to reclaim this disk space?
The Component Based Servicing (CBS) log is a critical Windows diagnostic file that records details about Windows Update installations, service pack applications, and other system changes. Normally, Windows should:
- Maintain a current
CBS.log
for active operations - Periodically archive older entries into compressed
.cab
files - Remove archives older than 30 days (by default)
Several scenarios can prevent proper CBS.log rotation:
# Common causes for CBS.log bloat:
1. Windows Update service constantly running (never idle for rotation)
2. Insufficient disk space for cab creation
3. Permission issues in C:\Windows\Logs\CBS
4. Anti-virus software blocking log rotation
5. Manual log truncation disrupting the rotation cycle
For immediate space recovery, follow these steps:
@echo off
:: Safe CBS.log cleanup script for Server 2008 R2
net stop wuauserv
takeown /f C:\Windows\Logs\CBS\CBS.log
icacls C:\Windows\Logs\CBS\CBS.log /grant administrators:F
copy /y nul C:\Windows\Logs\CBS\CBS.log
net start wuauserv
Alternatively, using PowerShell:
# PowerShell alternative
Stop-Service -Name wuauserv -Force
(Get-Item 'C:\Windows\Logs\CBS\CBS.log').Attributes = 'Normal'
Clear-Content -Path 'C:\Windows\Logs\CBS\CBS.log'
Start-Service -Name wuauserv
Implement these registry tweaks for better log management:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing]
"LogLevel"=dword:00000001
"LogSessionCount"=dword:00000005
"LogSize"=dword:00002000
Key values:
- LogLevel
: 1 (errors only) instead of 3 (verbose)
- LogSessionCount
: Limits archived logs
- LogSize
: Maximum size in KB (8192 KB shown)
Create a scheduled task to monitor CBS.log size:
schtasks /create /tn "Monitor CBS Log" /tr "powershell.exe -nologo -noprofile -command
\"if ((Get-Item 'C:\Windows\Logs\CBS\CBS.log').length -gt 500MB) {
Get-Process TrustedInstaller -ErrorAction SilentlyContinue | Stop-Process -Force;
Clear-Content 'C:\Windows\Logs\CBS\CBS.log';
Start-Service -Name wuauserv
}\"" /sc daily /st 23:00 /ru SYSTEM