BookmarkSubscribeRSS Feed
siddhu1
Obsidian | Level 7

Need to create a automated script in (Windows 2019 Servers) to clear the Log/temp files in the Midtier.

We have 1meat, 1mid and 2 compute Servers.

Right now we are doing it on manually, Need to automate to clear the files.

 

\Config\Lev1\Web\WebAppServer\SASServer1_1\logs
\Config\Lev1\Web\WebAppServer\SASServer1_1\temp
\Config\Lev1\Web\WebServer\logs 

 

4 REPLIES 4
gwootton
SAS Super FREQ
I do not have such a script for Windows but I did write something similar for Linux that would essentially delete any files older than a set number of days in given folders, or in the case of midtier logs that don't roll by date (server.log or the web app logs) remove the lines prior to the date of the set number of days prior. I'm sure it would be possible to write such a script in PowerShell for Windows, but this is not a function of SAS.
--
Greg Wootton | Principal Systems Technical Support Engineer
angian
SAS Employee

You need to be aware of not accidentally deleting "live logs".  For this reason, I only run log "Cleanup" scripts when I take all SAS services down for monthly maintenance.  I do schedule a cleanup on logs that are not live like batch logs and have some logic to delete files based on last modified date.  I have attached some script snippets to hopefully give you some inspiration.  I tend to wrap PowerShell scrips inside .cmd commands...but YMMV as there are so many ways to do things.

 

Task.PNG

 

angian
SAS Employee
I accidentally replied to gwootton....please see that reply....
Sajid01
Meteorite | Level 14

Looks like there is a logrotate  like utility available on windows. The details are available at GitHub - plecos/logrotatewin: This is a Windows implementation of the logrotate utility found in Lin... 
On Unix/Linux this is used routinely to archive and then remove old logs.
However, for windows recommend testing and due diligence before using it.
In case you adopt it please share your experiences for the benefit of other users.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 826 views
  • 1 like
  • 4 in conversation