There are different processes that use temporary directory space for different purposes.
- The operating system
(you haven’t given any information about your operating system, so for the sake of simplicity I’ll assume Ubuntu here)
/tmp
:
mounted as tmpfs
, which is in fact inside of the RAM of the server. It is not persistant between reboots.
If nothing else is defined, both php and nextcloud use that directory for temporary files.
However, php and nextcloud can define different temporary directories, which makes it easier to find out exactly which processes the temporary files come from.
In php there are the directives
These are mapped to the environment value of TMPDIR (/tmp
by default), but can be set to, for example:
sys_temp_dir = "/tmp_php"
upload_tmp_dir = "/tmp_upload"
Those directives must be defined in the php.ini of the SAPI used by your Nextcloud
either
/etc/php/<php-version>/fpm/php.ini
for php-fpm
/etc/php/<php-version>/apache2/php.ini
for libapache2-mod-php
Additionally you can pass your own environment variables in your pool-file (php-fpm):
env[TMP] = /tmp_php
env[TMPDIR] = /tmp_php
env[TEMP] = /tmp_php
Then there is the nextcloud config/config.php
option tempdirectory
, which can be set to an own directory.
'tempdirectory' => '/tmp_nc',
All of these directories must exist (they are not automaticaly created) and must be writable by whatever user PHP is running as.
Now you can monitor all movements in those directories with tools like inotify or auditd. You can write a script that logs everything using tools like inotifywayt, fuser, lsof etc.
When you have done that, you dont need to assume things because then you know it.
However, temporary files are really only temporary. They are usually deleted, but sometimes the deletion process fails. There can be many reasons for that.
So the only thing that is really interesting is which files are not deleted. You should examine them more closely to determine exactly where they come from. Then you can get to the bottom of the cause better.
It are often files from processes that are not from Nextcloud itself, such as the creation of preview images or other tasks triggered by specific apps.
Much and good luck,
ernolf