Home » BI Admin

Administration: Cleaning Up the WORK Library Automatically in UNIX

Submitted by on March 19, 2012 – 7:54 am 7 Comments

sas clean your unix work directory with cron job

Here is a quick tip for keeping the WORK library clean in a UNIX/Linux environment.  Most of the time SAS manages the cleanup process very well but sometimes orphaned processes can leave unwanted data lying around which can build up over time.  This tip is only applicable for UNIX or Linux environments.  SAS does come with a cleanwork utility which can be configured.  This approach could be used as a last resort in case the cleanwork utility fails.

 

Use a Shell Script for UNIX Heavy Lifting

This simple shell script will find all WORK directories created by SAS sessions and recursively remove everything within each directory older than a set time frame.  The joys of shell scripting!  :-)

#!/bin/sh

WORK=/sas/work

find $WORK/* -mtime +3 -exec rm -rf {} \;

exit 0

The WORK variable is set to the physical path of the WORK library on the compute server.  The number 3 represents the number of days since the file was last modified.  When this script is run, it initiates the find command which finds everything starting from the set directory with a last modified date older than 3 days, then forcibly removes everything within.  To prevent any permission problems, it should be run as ‘root’ or any other super user. 

Why Not Schedule It?

This shell script can be scheduled with cron or whatever scheduling system manages the server.  Personally I prefer cron because it just works!  More information about cron can be found here.

Tags: , , ,

x
Loading...
%d bloggers like this: