Rtmpxyz.. created by R session in /tmp are not cleaning up after session termination

Rtmpxyz.. created by R session in /tmp are not cleaning up after session termination. This accumulates over time and server becomes not usable

R cleans up the temporary directory on exit, if it gets a chance. However, sometimes it does not get a chance, e.g. if the R process is killed for some reason.

R is not unique in this respect. Every tool that uses temporary files might exit without a change to clean them up. In general it is good practice to set up automatic /tmp cleaning on server machines. There are several tools available for this.

Dear Gabor, thank you for your reply. Is the temporary directory created by R instead of Posit Workbench?

It appears that the cleanup of the temporary directory fails frequently, and users are accumulating GBs of data at a rapid rate. The solution that was suggested to us, cleaning up /tmp data regularly based on age of the file and foldes has numerous drawbacks.

The scripts suggested cleaning up data that is older than one month.

Firstly, we have sessions that run longer than a month. In this case we would remove the temporary data from a running session.

Secondly, some users accumulate hundreds of Gigabytes quickly, so removing data after one month might be too late to prevent the server from crashing and affecting other users.

Can you recommend tools that check if a session to which the temp folder belongs still exists and clean the data up if the session does not exist anymore?

Can you name/recommend some of the tools you mention in your message?

Thank you,

Marek

Yes, the Rtmp... directories are created by R.

In that case you probably need to implement your own cleanup mechanism. E.g. your long running process could keep a certain file open in the temporary directory and you'd only clean up the temporary directories that do not have that file open.

I don't know if there is a cleanup tool that can do this, but you can write a cron job to do it.

Or maybe tmpreaper [1] with atime would work for you.

[1] Ubuntu Manpage: tmpreaper - removes files which haven't been accessed for a period of time