Using tabadmin to Clean House and Free Storage Space

Using tabadmin to Clean House and Free Storage Space

A dirty house.

The joy of .txt files engorging themselves to massive sizes.  Seeing a production server with 80GB, 45GB, and 25GB .txt files for VizQL logging is entertaining, but really points to some poor house-keeping habits.  While reviewing the Tableau server with WinDirStat, I also noticed nearly 50GB in log files from 1-500MB in size on the server, which continued to bloat daily.  My house was dirty and needed a cleaning.    

Cleaning up.

Tableau provides an all-in-one cleaning tool to help get the house in order.  The cmdlet tabadmin provided by Tableau is recommended for removing unneeded files and is well suited for use in server maintenance.  To amplify the power, tabadmin cleanup --restart needs to be turned into a regular, verbose, and automated portion of Tableau production server maintenance.  

Read on for more details in how the solution is implemented, or download the script and get to having fun!   

Optional: Schedule with Windows Task Scheduler

To scheule with Windows Task Scheduler, copy the string below and replace the path with your own installation directory.  For more information on how to use Task Scheduler, follow my other article Sending PDF Tableau Dashboards Automatically Through Your Organization.

powershell -NoProfile -Executionpolicy bypass -file "c:/path/file.ps1"

Using tabadmin to clean house

Here is the code contained in the tabadminCleanupWarmup.ps1 file.  

#Create log function 
    #logfile path 
    $logfilepath = 'log.txt'
function write-log ([string]$logtext)
{
    "$(get-date -f 'yyyy-MM-dd hh:mm:ss'): $logtext" >> $logfilepath
}
#start the log recording 
write-log("Starting the process...")

$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
 
$OutputFileLocation = "log.txt"
Start-Transcript -path $OutputFileLocation -append
 
# about_Redirection http://bit.ly/2kHT1tQ
tabadmin cleanup --restart 2>&1 | out-host


tabadmin warmup 2>%1 |out-host

Stop-Transcript
write-log("Process completed. ")

I use some less than graceful methods of getting a verbose log of what the script is performing, but it gets the job done.  My usually method of logging in PowerShell involves the custom function write-log shown above.  Each script that uses this function makes slight modifications to the same core process of piping the output and select variables as a string into the log file.  In this example, I need to get all of the details that tabadmin.exe reports to the console; however, there are some limitations to Start-Transcript.  To address these limitations I've used a combination of the write-log custom function and about_Redirection.  I recommend reading the MSDN article on about_Redirection as it explains the limitations to how verbose the console can be when pipping the output to a log and will do a detailed job of expanding on the arguments used in this script.  

Related Tableau Resources

The following links were used in the creation of my solution:

Happy Dashboarding!

Drill Deeper: Mapping Geolocation in Tableau

Drill Deeper: Mapping Geolocation in Tableau

Using T-SQL To Validate and Convert a FLOAT to DATETIME