Finding and deleting orphaned SAS WORK and SAS Utility directories

16

SAS administrators often ask for a utility that can detect orphaned SAS WORK and SAS Utility directories on their back-end SAS compute systems. These orphaned directories result when a SAS Enterprise Guide or any other SAS GUI application is terminated incorrectly, and the SAS session does not terminate properly.

SAS has written utilities to detect these directories and delete them.

For UNIX/Linux, you use the cleanwork utility in the !SASHOME/bin/utilities directory that has been shipping with SAS since SAS 8.2.  The utility deletes any leftover SAS WORK and SAS Utility directories that were associated with a SAS process that has ended.   For more details, please refer to the cleanwork command documentation in the SAS 9.4 Companion for UNIX Environments.

For Windows, SAS has recently been promoting the SAS Disk Cleanup Handler Utility.  This utility searches for and cleans any temporary files that SAS generates, as well as any SAS WORK and SAS Utility directories.  SAS Disk Cleanup Handler is a COM hook into the Microsoft Disk Cleanup Handler (cleanmgr.exe).  For more details, please refer to the SAS Disk Cleanup Handler Utility documentation in the SAS 9.3 Companion for Windows.  Please note that this version of the utility is available with SAS 9.2 and SAS 9.3.

Starting with SAS 9.4M2, there is a new stand-alone utility – cleanwork.exe – that you can use with any version of SAS, starting with SAS 6.

We have placed this utility along with its documentation on the SAS FTP download page:

Many of our SAS administrators who are using these utilities have them scheduled to run once a week or once a month, depending on the frequency of their SAS users incorrectly terminating SAS sessions or the amount of free space they have in the SAS WORK and SAS Utility file systems.

 

 

Share

About Author

Margaret Crevar

Manager, SAS R&D Performance Lab

Margaret Crevar has worked at SAS since May 1982. She has held a variety of positions since then, working in sales, marketing and now research and development. In her current role, Crevar manages the SAS Performance Lab in R&D. This lab has two roles: testing future SAS releases while they're still in development to make sure they're performing as expected; and helping SAS customers who are experiencing performance issues overcome their challenges.

Related Posts

16 Comments

  1. Thanks for the information Margaret. However, based on my personal experience the 'cleanwork' utility does not delete the folders which are still locked by orphaned processes.

    Is there any way out of this?

    • Margaret Crevar
      Margaret Crevar on

      If the command is run by root it should delete all the SAS folders. Please let me know if this is not the case.

    • Kurt Bremser on

      You have to terminate the "dead" processes first. I have to do that regularly for CONNECT sessions where the client was simply turned off. After the owning process is gone from the process list, cleanwork does its duty.
      Killing other user's process requires superuser/system privilege, though.

  2. Michael A. Raithel on

    Margaret,

    Great article as always!

    I have two questions:

    1. Is the Cleanwork Utility for Windows aimed solely at Windows servers, or will it also run on Windows workstations?

    2.Can the cleanwork.exe stand-alone utility be run on Windows workstations?

    Thank you.

    ----MMMMIIIIKKKKEEEE
    (aka Michael A. Raithel)

    • Margaret Crevar

      The cleanwork.exe will run on Windows Vista and newer. And Window Server 2008 R2 and newer. Hope that helps..

  3. Handy - but these open up the disk space without actually cleaning the data from the drive, do they not? We've got sensitive data. What would be useful is a way to initiate a process to wipe the temporary files when the SAS session is shut down, by overwriting it with random bits.

    Has anybody heard of such a thing?

    • Margaret Crevar

      I checked with SAS R&D, and this is the first time they have heard of a request for this feature. Please remember that files come and go in the SASWORK area during the SAS session and when SAS shuts down properly they are deleted to make room for the next SAS session to create files in.

      With all the SAS sessions using a single directory/folder for SAS WORK, the space will be overwritten often, so that should help with making sure your sensitive data can not be restored.

      Please let me know if you have questions on this information.

      • Margaret,
        Using a single directory/folder for SAS WORK does not mean that all SAS sessions use the same disk areas. Even if files are stored in the same directory, they may be physically on different disk areas, especially when there is a lot of free space on the disk.

        • Margaret Crevar

          You are correct, but most companies SAS WORK area generally runs 75% full each day. So the odds of another SAS session creating a SAS WORK directory and writing over the disks from a previous SAS session are very high.

          Also, SAS does not write in contiguous disk space on a single disk, it writes the SAS data files across multiple disks. As soon as any segment of the previous SAS data file that was written is written over, then the entire SAS data file can not be restored.

  4. I understand that this is admin functionality but is there a command that any SAS programmer can run to get a list of workspace usage by all SAS user ids? Would be easy to contact one user, rather than send an email to the admin and wait to get the report and then send it to the entire team.

    • Margaret Crevar
      Margaret Crevar on

      NP, There are several ways to do this. One is via SAS RTM that has been part of SAS Grid (but this way may require administration privileges). However, starting with SAS 9.4 M3 a lot of the RTM functionality has been added to SAS Environment Manager, and part of that functionality is for you to be able to do real time monitoring of SAS jobs running on your system as a SAS user. More details can be found here: http://support.sas.com/documentation/cdl/en/gridref/67944/HTML/default/viewer.htm#p0own65b1n5xgan10u8aq3ippe3l.htm

      You can also look and writing a SAS job/macro that can be executed via SAS Enterprise Guide to get similar information. We can share this code with you if you would like.

      • I'm interested in the code for the SAS job/macro that can be executed via SAS Enterprise Guide to get similar information. Thanks.

    • Richard Collins on

      NP - check out worktop: https://github.com/Boemska/worktop

      It's a bash script which monitors your saswork mounts, highlighting those which breach a configurable threshold. Very simple to use, download, add execute rights and run. With a bit of tweaking of the workspace server config it can display the metauser for the sas session

  5. Small correction: for Linux (and presumably UNIX), cleanwork is in the !SASHOME/utilities/bin/ directory, not the !SASHOME/bin/utilities directory.

  6. Margaret,

    Hope all is well. Can we use this prior to an image to reduce overall image size? I am running on a Windows Server instance and need to do an image prior to backup.

    Thanks,
    Alan

Leave A Reply

Back to Top