По умолчанию каталог tmp очищается при каждой (повторной) загрузке.
You can set the live time in days by increasing TMPTIME
in the following file: /etc/default/rcS
.
I'm not aware of any automatically clean up process for temp directory during runtime. But it should be possible with a little script which is called by cron and deletes older files. Note do not delete files in the tmp directory you are not aware of - the best would be to save your uploads within a separate directory in tmp.
Вы должны хотя бы знать о настройках папки.
Это файл по умолчанию / etc / rcS
.
$: cat /etc/default/rcS
#
# /etc/default/rcS
#
# Default settings for the scripts in /etc/rcS.d/
#
# For information about these variables see the rcS(5) manual page.
#
# This file belongs to the "initscripts" package.
# delete files in /tmp during boot older than x days.
# '0' means always, -1 or 'infinite' disables the feature
TMPTIME=0
# spawn sulogin during boot, continue normal boot if not used in 30 seconds
SULOGIN=no
# do not allow users to log in until the boot has completed
DELAYLOGIN=no
# assume that the BIOS clock is set to UTC time (recommended)
UTC=yes
# be more verbose during the boot process
VERBOSE=no
# automatically repair filesystems with inconsistencies during boot
FSCKFIX=no
В общем, вы можете здесь есть грубый контроль зернистости, когда следует удалять, и более тонкий контроль, если вы настроили задание cron
, как вы предлагаете. Возможно, определенные типы файлов будут удалены раньше в вашем задании cron, чем, например, здесь.