I have a ubuntu 14.04 virtual machine on azure, with a OS disk of size 30 GB.

If I keep the machine running for several days, the size of the /tmp folder increases upto 21 GB, and adding up other folders it reaches its limit i.e., 30 GB and the VM stops functioning.

Yes, after restarting the VM the size of /tmp folder is back to 1 GB and the VM starts functioning. But, I do not want to restart the system everytime the limit is reached.

Could anyone please help me with any other solution for this issue?

  • Please post the output of cat /etc/fstab – StrabagISS_Krall Jan 13 at 14:43
  • 14.04 is EOL by the way, and not supported any more here. As for the system constantly using up /tmp/ that's not a good thing and should be investigated, as it sounds like you've got something doing things it shouldn't or not cleaning up after itself. Alternatively, just reboot the system more regularly - reboots will empty out /tmp. – Thomas Ward Jan 13 at 15:08

You can implement a script to empty the /tmp directory every hour like so:

  1. Create and edit a script file in your home directory by running the following command in the terminal:

    nano ~/EmptyTmp.sh

  2. Copy and paste the following code into the editor:


while true
                sleep 1h
                find /tmp/{*,.??*} -exec rm -rf {} \;

  1. Save the script file and exit the editor by pressing Ctrl + X then press Y.

  2. Make the script file executable by running the following command in the terminal:

    chmod +x ~/EmptyTmp.sh

  3. Run the script by running the following command in the terminal:

    sudo bash ~/EmptyTmp.sh

Done, /tmp will be emptied every hour.

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