This is een export of a job to remove all empty log files under DnnSharp directory older dan 1 day.
It uses the root of the application from a token, runs a Powershell script at 01:00 AM and logs a count of the deleted files. You can import the content below in automation. After import refresh the page as it is not always directly visible. Tested in 1.21 and 1.27
{
"GlobalId": "7a10937d-7eda-46a3-99ec-d57b38e10868",
"IsDebug": false,
"Name": "Remove empty log files",
"ContextUser": null,
"ContextPortal": 0,
"ContextUsername": null,
"IsEnabled": true,
"IsDeleted": false,
"IsSystem": false,
"LastModifiedBy": 1,
"ConcurrencyToken": "fce0db520065468d94e40a1648248d7d",
"LastModified": "2026-01-22T14:58:34.5273545Z",
"Actions": [
{
"ActionType": "ApplyTokens",
"ExecutionType": "OnExecute",
"OrderIndex": 0,
"Condition": null,
"Description": "log path",
"IsDeleted": false,
"IsDisabled": false,
"Parameters": {
"TokenizeTokenNames": "",
"RecursionCount": "1",
"Tokens": [
{
"name": "logpath",
"value": "[ServerVars:APPL_PHYSICAL_PATH]Portals\\_default\\Logs\\DnnSharp"
}
]
}
},
{
"ActionType": "RunPowerShellScript",
"ExecutionType": "OnExecute",
"OrderIndex": 1,
"Condition": null,
"Description": "remove non-empty log files",
"IsDeleted": false,
"IsDisabled": false,
"Parameters": {
"Script": "$basePath = \"[logpath]\"\n$removedCount = 0\n$cutoffDate = (Get-Date).AddDays(-1)\n\nGet-ChildItem -Path $basePath -Recurse -Directory | ForEach-Object {\n\n $logFiles = Get-ChildItem -Path $_.FullName -File -Filter \"*.log.resources\" |\n Sort-Object LastWriteTime -Descending\n\n if ($logFiles.Count -gt 1) {\n # Files older than 1 day, excluding the newest file\n $filesToRemove = $logFiles |\n Select-Object -Skip 1 |\n Where-Object { $_.LastWriteTime -lt $cutoffDate }\n\n $removedCount += $filesToRemove.Count\n $filesToRemove | Remove-Item -Force\n }\n}\n\n# Output the total number of deleted files\n$removedCount\n",
"OutputTokenName": "RemovedFilesCount"
}
},
{
"ActionType": "LogEvent",
"ExecutionType": "OnExecute",
"OrderIndex": 2,
"Condition": null,
"Description": "add admin log message",
"IsDeleted": false,
"IsDisabled": false,
"Parameters": {
"EventType": {
"Value": "ADMIN_ALERT",
"IsExpression": false,
"Expression": ""
},
"UserID": "1",
"LogProperties": [
{
"name": "EmptyFilesRemoved",
"value": "[RemovedFilesCount]"
}
]
}
}
],
"OnErrorActions": [],
"Triggers": [
{
"Id": 20,
"IsEnabled": true,
"TriggerDefId": "Daily",
"LastModified": "2026-01-22T15:58:34.5273545+01:00",
"LastModifiedBy": 1,
"Parameters": {
"Time": "01:00 AM",
"SkipIfRunning": true,
"OnMissfire": {
"Value": "DoNothing",
"IsExpression": false,
"Expression": null
},
"DaysOfWeek": {
"MON": true,
"TUE": true,
"WED": true,
"THU": true,
"FRI": true,
"SAT": true,
"SUN": true
}
},
"IsDeleted": false
}
],
"LastRunStartUtc": "2026-01-22T15:00:00.3241511+00:00",
"LastRunEndUtc": "2026-01-22T15:00:00.4022915+00:00",
"LastStatus": 2,
"ThreadsInUse": 0,
"LastJobData": {},
"NextRunUtc": "2026-01-23T01:00:00+00:00",
"NamespaceGuid": "312a26af-cd0e-4943-bc76-7d9636b1e119",
"NamespaceName": "Default"
}