我正在构build一个Web应用程序,我的用户将能够上传文件。 file upload后,我需要将文件发送到另外两台服务器,并将其从服务器上传到服务器后删除。
我徘徊是一个很好的想法,保持上传的文件在tmp /文件夹的时间上传的文件发送到其他两台服务器,或者我应该将它们移动到另一个文件夹,因为他们被删除? 我也徘徊,因为我想知道是否必须build立一个cron脚本来摆脱已转移到其他服务器的文件,以便我得到我的磁盘空间。
默认情况下,在每次(重新)启动时清理tmp目录。 您可以通过在以下文件中增加TMPTIME来设置实时时间: /etc/default/rcS 。
我没有意识到在运行时会自动清除临时目录的进程。 但应该可以用一个由cron调用的小脚本来删除较旧的文件。 请注意,不要删除tmp目录中您不知道的文件 – 最好的做法是将您的上传文件保存在tmp的单独目录中。
你至less应该知道文件夹的设置。
这是一个默认的/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
所以,基本上,您可以在这里进行粗略的控制,以便在何时删除,以及如果您要build立cron job ,则可以进行更好的控制。 例如,某些types的文件可能会在您的cron作业中比此处的设置更早被删除。