Architecting, installing and maintaining your SAS environment

Workspace Cleanup

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Workspace Cleanup

Hi, 

Me and my team have been working in SAS now for 5 months.
And I would like assistance on how to clean-up our workspace storage and have this process automated.

We currently running our sas servers on an unix enviroment, and our workspace directory fills up pretty quickly which effects users.
What we find is that SAS doesn't always delete workspace files from sessions that are obsolete. So we need a non-manual way to delete these.

Someone in this community recommended we use a:cleanwork utility:

/sas/SASHome/SASFoundation/9.4/utilities/bin

 

I have not used this uitlity and we would like to know how we execute this command, and what are its effects?
I further would like recommndations on best practices on how to manage our workspace. 


Accepted Solutions
Solution
3 weeks ago
Regular Contributor
Posts: 211

Re: Workspace Cleanup

The easiest way to use cleanwork is to schedule it every 15 mins in cron under root on every compute server. The format is :

 

/sas/SASHome/SASFoundation/9.4/utilities/bin/cleanwork /my_work_folder_1

/sas/SASHome/SASFoundation/9.4/utilities/bin/cleanwork /my_work_folder_2

...etc

 

This is really all you need to keep you work directories clean. However, this doesn't prevent abuse of your workspace nor the cleanup of orphan processes. cleanwork only cleans up work folders that are not in use. If an orphan process is holding it, it's is seen as 'in use' by cleanwork.

View solution in original post


All Replies
Solution
3 weeks ago
Regular Contributor
Posts: 211

Re: Workspace Cleanup

The easiest way to use cleanwork is to schedule it every 15 mins in cron under root on every compute server. The format is :

 

/sas/SASHome/SASFoundation/9.4/utilities/bin/cleanwork /my_work_folder_1

/sas/SASHome/SASFoundation/9.4/utilities/bin/cleanwork /my_work_folder_2

...etc

 

This is really all you need to keep you work directories clean. However, this doesn't prevent abuse of your workspace nor the cleanup of orphan processes. cleanwork only cleans up work folders that are not in use. If an orphan process is holding it, it's is seen as 'in use' by cleanwork.

New Contributor
Posts: 3

Re: Workspace Cleanup

Thank you @nhvdwalt

 

This was a simple usage of the cleanwork utility and has worked. Are there any further recommendations you may have in regards to scheduling this tool to frequently execute every 30min?

Super User
Posts: 8,037

Re: Workspace Cleanup

If you want to run your cleanwork every 30 minutes, switch to the root account, run

crontab -e

and add the following line (since crontab -e uses vi, scroll to the last line, type A (capital a), and then <enter> for a new line):

5,35 * * * * /sas/SASHome/SASFoundation/9.4/utilities/bin/cleanwork your_work_dir >/dev/null 2>&1

hit <escape>, : (colon), x and <enter> to exit vi with writing the changed crontab; it will be active from then on.

The >/dev/null 2>&1 redirects all stdout and stderr output to the bit bucket; otherwise you'd get mails for every execution.

 

Another way to edit the crontab is this:

crontab -l > crontab

creates a file named "crontab" in the current directory. Edit that with an editor of your choice, and then run

crontab crontab

to create the new crontab entry from that file. Make sure that all existing entries are kept as-is.

 

Running cleanwork from root is necessary as the WORK directories will belong to different users, and only root can remove them all.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Regular Contributor
Posts: 211

Re: Workspace Cleanup

Hi @LNTLOKO

 

I see @KurtBremser gave a very good explanation about cron.

 

Are you sorted now ?

Super User
Posts: 8,037

Re: Workspace Cleanup

In addition to @nhvdwalt:

if you want to be proactive in managing shared resources, you will need to use filesystem quotas, so individual users can not use up all space and ruin the day for all others. This is true for all resources where users have been granted write access; you can omit it where small groups of users are involved (that can handle the management by themselves), and where the non-availability of a resource will not cause a business-critical problem.

 

In our case, that is the home filesystem, and all WORK/UTILLOC locations.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 436

Re: Workspace Cleanup

Posted in reply to KurtBremser

Could you please help me with the document about file system quotas to prevent the users from consuming all space?

Super User
Posts: 8,037

Re: Workspace Cleanup

Maxim 6: Google is your friend.

Do a search for "linux filesystem quotas", and you'll end up with a mountain of useful resources, the first being http://www.yolinux.com/TUTORIALS/LinuxTutorialQuotas.html.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 447

Re: Workspace Cleanup

The cleanwork utility is your way to go and others have already replied on how it works.

 

On a side note I would be interested in why your work grows so quickly. In the ideal situation, when SAS terminates in an intended fashion ( a user quits the SAS session; a SAS job end) the work library is deleted automatically. Any residual work locations are due to SAS sessions that end in a less fortunate way because they crash or are killed by some administrative action. If you have many of these this may require some investigation.

 

Start with checking the value of the WORKTERM option. By default it is WORKTERM; the opposite, NOWORKTERM, will cause your WORK libraries to persist. I have never seen that being the default but you never know. If WORKTERM is the default, dig deeper.

 

Regards,

- Jan.

SAS Employee
Posts: 129

Re: Workspace Cleanup

Hi @LNTLOKO

 

Nothing to add about cleanwork that was not already mentioned but you may want to use the Checklist of SAS® Platform Administration Tasks document.

Strange enough, it lists cleanwork Smiley Very Happy

 

Cheers,
Damo

New Contributor
Posts: 3

Re: Workspace Cleanup

Thank you Damo. I've had a look at this one, and it does list the task for how we're planning to manage the usage on our envoroment.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 256 views
  • 2 likes
  • 6 in conversation