I am building a web application where my users will be able to upload files. After the files are uploaded I need to send the files to two other servers, and after they will be deleted from the server where they were just uploaded to.

I am wandering is it a good I idea to keep the uploaded files in the tmp/ folder the time the uploaded files are sent to the other two servers or should I move them to another folder incase they get deleted? I am also wandering because I would like to know if I have to build a cron script to get rid of the files that have been transfered to the other servers so that I get my disk space back.

  • I have a colleague who likes to put log files in /tmp/. Some of them have been there for years. – Ladadadada Dec 5 '12 at 9:20
  • 1
    @Ladadadada One of these days, your colleague is in for a very unpleasant surprise. – Michael Hampton Dec 5 '12 at 14:30
  • ^lol! You are funny. – jnbdz Dec 5 '12 at 19:12

By default the tmp directory is cleaned up at every (re)boot. 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.


You should at least be aware of the settings for the folder.

Here is a default /etc/rcS file.

 $: 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                    

# spawn sulogin during boot, continue normal boot if not used in 30 seconds  

# do not allow users to log in until the boot has completed                  

# assume that the BIOS clock is set to UTC time (recommended)                

# be more verbose during the boot process                                    

# automatically repair filesystems with inconsistencies during boot          

So basically, you can have the rough grain control here for when to delete, and a finer control if you were to setup a cron job as you are suggesting. Perhaps certain kinds of files get deleted sooner in your cron job than the setting here, for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.