The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to empty /tmp folder?

Discussion in 'Workarounds and Optimization' started by Spetsnaz, Oct 3, 2012.

  1. Spetsnaz

    Spetsnaz Well-Known Member

    Joined:
    Jun 25, 2011
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    This is my question because it is full to the max!
     
  2. anupkumar

    anupkumar Member

    Joined:
    May 20, 2011
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    check the tmp folder and if sess_* files are present under /tmp then you can delete that files.
     
  3. Spetsnaz

    Spetsnaz Well-Known Member

    Joined:
    Jun 25, 2011
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    How can I do this? I couldn't really understand what everyone was taking about.
     
  4. pwhjenny

    pwhjenny Well-Known Member

    Joined:
    Aug 31, 2012
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    What files filling up your /tmp partition?
     
  5. Spetsnaz

    Spetsnaz Well-Known Member

    Joined:
    Jun 25, 2011
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    here is an example of most

     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
  7. Spetsnaz

    Spetsnaz Well-Known Member

    Joined:
    Jun 25, 2011
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    Well I was just checking I just wanted to delete all the files but no director
     
  8. pwhjenny

    pwhjenny Well-Known Member

    Joined:
    Aug 31, 2012
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    You can just execute to delete all session files but i would not suggest to delete recent files as users may get session file errors.

    rm -rf sess*
     
  9. Spetsnaz

    Spetsnaz Well-Known Member

    Joined:
    Jun 25, 2011
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    Alright, and may I ask like recent files.
    such as if they uploaded index.php 1minute ago it will be gone?
     
  10. pwhjenny

    pwhjenny Well-Known Member

    Joined:
    Aug 31, 2012
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    You should change directory to /tmp fils and then execute command I gave. You need to make sure your working directory before deleting any files on the linux server. You can check working directory by using pwd command. Many script generates session files after every seconds. You can use mtime argument with the find command to search out little bit old files say 1 hour older. So if you delete them it wont cause much effect for your website.
     
  11. Spetsnaz

    Spetsnaz Well-Known Member

    Joined:
    Jun 25, 2011
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    root@server1 [/usr/src]# pwd
    /usr/src

    What do you mean change directory to /tmp files and then execute?
     
  12. pwhjenny

    pwhjenny Well-Known Member

    Joined:
    Aug 31, 2012
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    cd /tmp

    and then run rm command to delete session file.
     
  13. siriusb

    siriusb Member

    Joined:
    Mar 10, 2009
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Argentina
    cPanel Access Level:
    Root Administrator
    1) List files with more than 7 days in /tmp and subdirs

    find /tmp/ -type f -mtime 7 | less

    2) delete if everything is ok

    find /tmp/ -type f -mtime 7 -exec rm -f {} \;
     
  14. Torro99

    Torro99 Registered

    Joined:
    Oct 28, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    try some of the steps below, may be helpful.

    1.) Stop MySql service and process kill the tailwatchd process.
    2.) Take a backup of /tmp as /tmp.bak
    3.) Create a 2GB file in the avaliable freespace
    [root@server ~]# dd if=/dev/zero of=/usr/tmpDSK bs=1024k count=2048
    쎀+0 records in
    2048+0 records out
    2147483648 bytes (2.1 GB) copied, 73.6908 seconds, 29.1 MB/s
    [root@server~]# du -sch /usr/tmpDSK
    2.1G /usr/tmpDSK
    2.1G total

    4.) Assign ext3 filesystem to the file
    [root@server~]# mkfs -t ext3 /usr/tmpDSK
    mke2fs 1.39 (29-May-2006)
    /usr/tmpDSK is not a block special device.
    Proceed anyway? (y,n) y
    Filesystem label=
    OS type: Linux
    262144 inodes, 524288 blocks
    26214 blocks ƕ.00%) reserved for the super user
    First data blockɢ
    Writing inode tables: done
    Creating journal (163ȴ blocks): done
    Writing superblocks and filesystem accounting information: done
    This filesystem will be automatically checked every 25 mounts or
    180 days, whichever comes first. Use tune2fs -c or -i to override.

    5.) Check the file system type:-
    [root@server ~]# file /usr/tmpDSK

    /usr/tmpDSK: Linux rev 1.0 ext3 filesystem data (large files)
    Note:-

    6.) Unmount /tmp partition
    [root@server ~]# umount /tmp

    7.) Mount the new /tmp filesystem with noexec
    [root@server ~]# mount -o loop,noexec,nosuid,rw /usr/tmpDSK /tmp

    8.) Set the correct permission for /tmp
    [root@server ~]# install -d –mode=1777 /tmp
    [root@antg ~]# ls -ld /tmp
    drwxrwxrwt 3 root root 4096 Feb 6 08:42 /tmp

    ( you may use the command chmod 1777 /tmp for doing the same )
    [root@server ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda9 28G 6.4G 20G 25% /
    /dev/sda8 99M 10M 84M 11% /boot
    tmpfs 500M 0 500M 0% /dev/shm
    /usr/tmpDSK 2.0G 68M 1.9G 4% /tmp

    9.)Restore the content of old /tmp.bkp directory
    [root@server ~]# cp -rpf /tmp.bak/* /tmp

    10.) Restart the mysql and tailwathchd services.
    [root@server ~]# /etc/init.d/mysql start
    [root@server ~]# /scripts/restartsrv_tailwatchd

    11.)Edit the fstab and replace /tmp entry line with :-
    /usr/tmpDSK /tmp ext3 loop,noexec,nosuid,rw 0 0

    12.) Mount all filesystems
    [root@server~]# mount -a

    Check it now:-

    [root@server ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda9 28G 6.4G 20G 25% /
    /dev/sda8 99M 10M 84M 11% /boot
    tmpfs 500M 0 500M 0% /dev/shm
    /usr/tmpDSK 2.0G 68M 1.9G 4% /tmp

    maybe there are some points that I have written, if you want to clearer, try visiting /http://www.boxtutorials.com/how-to-increase-the-size-of-disk-space-tmp-usrtmpdsk-partition-in-linux-server.html much of what I get from there
    really hope this little tutoral can help you:)
     
  15. maceemiller

    maceemiller Registered

    Joined:
    Oct 28, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Thankyou. These two links exactly what I needed.
     
Loading...

Share This Page