• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Safe deletion of the contents of /tmp directories

learning_curve

Silver Pleskian
Having an interest in keeping things organised on our server, we ran several content queries.
The two items with results that may warrant some re-organisation are these two:
Code:
# du -sk /usr/local/psa/tmp/*
and this one:
Code:
# du -sk /var/tmp/*
The question is (for those with lots more Plesk experience than we have ;)) Can all of the following be safely deleted?
We have no issues with available disk size etc and the second one is very small but... We thought we'd ask!
The results from running: du -sk /usr/local/psa/tmp/*

0 /usr/local/psa/tmp/agent6237ba101d0d47aeea74fcf306b70bab
0 /usr/local/psa/tmp/app-data.d
0 /usr/local/psa/tmp/aps
108 /usr/local/psa/tmp/default_skeleton.tgz
4 /usr/local/psa/tmp/ftp.pamd
8 /usr/local/psa/tmp/plesk-default-key.xml
20 /usr/local/psa/tmp/run-root.tar
4 /usr/local/psa/tmp/sfdk_publicaN3hjS
4 /usr/local/psa/tmp/sfdk_publicEoDjCv
4 /usr/local/psa/tmp/sfdk_publicfzRQXg
4 /usr/local/psa/tmp/sfdk_publicj06nMj
4 /usr/local/psa/tmp/sfdk_publiclgUBwc
4 /usr/local/psa/tmp/sfdk_publicrCdZKs
4 /usr/local/psa/tmp/sfdk_publicxmgZMd
4 /usr/local/psa/tmp/sfdk_publicZ4NBRE
888 /usr/local/psa/tmp/tmp16QZqr
9724 /usr/local/psa/tmp/tmp1OCKEr
13908 /usr/local/psa/tmp/tmp2vpr8V
592 /usr/local/psa/tmp/tmp4tpK7O
12708 /usr/local/psa/tmp/tmp5fdrwp
3200 /usr/local/psa/tmp/tmpaMs8is
1228 /usr/local/psa/tmp/tmpbAzXto
1200 /usr/local/psa/tmp/tmpFLu3XC
1608 /usr/local/psa/tmp/tmpfouFvG
1276 /usr/local/psa/tmp/tmpFsTWke
12696 /usr/local/psa/tmp/tmpIknjb3
13112 /usr/local/psa/tmp/tmpJMg653
12744 /usr/local/psa/tmp/tmpmEn6IH
1216 /usr/local/psa/tmp/tmpnhGNlE
16732 /usr/local/psa/tmp/tmprlY6Fi
13684 /usr/local/psa/tmp/tmpU4EkZm
900 /usr/local/psa/tmp/tmpUAMzK7
17272 /usr/local/psa/tmp/tmpVFWL4K
1496 /usr/local/psa/tmp/tmpXc4ppp
33236 /usr/local/psa/tmp/tmpzxnxZi
4 /usr/local/psa/tmp/webserver_configuration_issues.log
followed by
The results produced from running: du -sk /var/tmp/*

4 /var/tmp/dgri.rpmhashes.0
4 /var/tmp/dgri.rpmhashes.988
0 /var/tmp/systemd-private-e7e622421f4a4ad5886faf08dd6ae101-dovecot.service-qcZ19Y
0 /var/tmp/systemd-private-e7e622421f4a4ad5886faf08dd6ae101-httpd.service-qwykkn
0 /var/tmp/systemd-private-e7e622421f4a4ad5886faf08dd6ae101-plesk-php71-fpm.service-twGSjn
0 /var/tmp/systemd-private-e7e622421f4a4ad5886faf08dd6ae101-vgauthd.service-7ZNT71
0 /var/tmp/systemd-private-e7e622421f4a4ad5886faf08dd6ae101-vmtoolsd.service-oemVi1
70544 /var/tmp/yum-dgri-report-3sWvuT
 
With my Plesk installation the /tmp dir is also already at close to 11GB with folders like "3ad38uu" and so on, all containing packages from the extension directory. I find it very annoying to see my disk space being eaten away by something like that. Really no idea why Plesk does this and why there's no kind of automatic cleaning mechanism. Especially on low capacity SSD servers this "eating storage" is not really acceptable.

Any advice on what to do? Can this safely be deleted or not? I'm asking because with 12.5 I once did and then I was thrown 502 Bad Gateway messages at me until I rebooted the whole server which in a production environment isn't a decision coming up easily.

It would be awesome if someone came up with a solution to stop this garbage piling up or at least have an automated job clean it from time to time.
 
Hi learning_curve and speedbird,

pls. feel free to setup cron tasks as for example:

Code:
find /var/tmp/ "systemd-private*" -mtime +1 -exec rm -f {} \;
( deletes found files with the name "systemd-private*" in the directory "/var/tmp/", which are older than 1 day )

or/and

Code:
find /usr/local/psa/tmp "tmp*" -mtime +1 -exec rm -f {} \;
( deletes found files with the name "tmp*" in the directory "/usr/local/psa/tmp", which are older than 1 day )


You might be as creative as you wish, by setting up such cron tasks on your server(s), but I never would recommend to delete folders/files at "tmp" - locations, which are younger than 1 day, as you then should first investigate if they are not actually being used by a current process. ;)

 
Thanks very much @UFHH01 helpful as always :)
We wanted to try these by running them manually first (before setting them up as cron jobs) so we did. Yes, all files are quickly deleted, but as coded, any directories / sub-directories are ignored (see a couple of examples below)
( deletes found files with the name "systemd-private*" in the directory "/var/tmp/", which are older than 1 day )
Code:
find /var/tmp/ "systemd-private*" -mtime +1 -exec rm -f {} \;
When running the above, a couple of sample lines include:​
Code:
# find /var/tmp/ "systemd-private*" -mtime +1 -exec rm -f {} \;
rm: cannot remove ‘/var/tmp/systemd-private-e7e622421f4a4ad5886faf08dd6ae101-dovecot.service-qcZ19Y/tmp’: Is a directory
rm: cannot remove ‘/var/tmp/yum-dgri-report-3sWvuT/x86_64/7/plesk-ext-readykernel/packages’: Is a directory
Similar results are obtained with the second coding that you provided.

For us to be absolutely sure in advance, is this a deliberate Plesk intention? i.e. delete files but retain directories / sub-directories or, can this be safely expanded to include files AND directories / sub-directories in these locations?
 
Hi learning_curve,

For us to be absolutely sure in advance, is this a deliberate Plesk intention? i.e. delete files but retain directories / sub-directories or, can this be safely expanded to include files AND directories / sub-directories in these locations?
Again, pls. be as creative as you desire, when using my recommendation for a cron task. I'm sure that you are able to expand such an example command to folders, subfolders, and the folders of the subfolders on your very own and I am pretty sure, that you might know, that "systemd" and "yum" - related temporary files are far away of a Plesk scope. ;) The idea to use "systemd-private*" is based on your provided informations and you might even use "*.*" to include all files within your FIND - search, if you desire that. :)

"/tmp" and "/var/tmp" might be used by Plesk, its components and extensions, but as you can see with your leftovers, other software on your server use these folders as well. Normally your system will take care of to empty these folders and there shouldn't be a need for any cron task at all. Consider to use the example command
Code:
lsof +D /tmp
... to see which files are currently in use.


It is hard to investigate, why you experience leftovers inside of "/usr/local/psa/tmp", but I recommended before, that I would never touch files, which are younger than one day, as they might be in use right now. You are able to check this with another example command like:
Code:
lsof +D /usr/local/psa/tmp
If you desire further informations for temporary Plesk - files leftovers, pls. consider to contact the official Plesk support, as deeper investigations directly on your server have to be done. :)
 
Excellent :D
Yes, we're super clear now and we'll expand these as we see fit / having pre-checked validity / usage etc first.
 
Back
Top