Page 1 of 6 123 ... LastLast
Results 1 to 10 of 57

Thread: The wisdom of emptying /tmp at boot time

  1. #1

    Default The wisdom of emptying /tmp at boot time

    opensuse 13.1

    While researching another topic, I came across a couple of suggestions in posts that emptying /tmp at boot time is a useful procedure, especially for reclaiming disk space. "Hmm," I thought, "maybe so."

    I would implement it by adding "@reboot cd /tmp; rm -fr *" to the root crontab.

    Is this a wise thing to do?
    What are its counterindications?

  2. #2
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,004

    Default Re: The wisdom of emptying /tmp at boot time

    I think it would be a better idea to use the systemd cleaning.

    Take a peek at:
    Code:
    /usr/lib/tmpfiles.d/tmp.conf
    If you make a copy of it in /etc/tmpfiles.d/ and edit that, it'll override the defaults.

    man tmpfiles.d will tell you all kind of fun things you can specify.
    .: miuku #suse @ irc.freenode.net
    :: miuku@opensuse.org

    .: h​ttps://download.opensuse.org/repositories/home:/Miuku/

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,869

    Default Re: The wisdom of emptying /tmp at boot time

    This is a not unnormal behaviour practised by many Unix/Linux system managers.

    It is also not unusual to make /tmp a separate file system of type tmpfs (or similar), that is in RAM, which will have almost the same effect (deletion is on shutdown and not direct after boot, but who will see the difference?)

    There is still the YaST way to configure this (YaST > System > /etc/sysconfig Editor and then System > Cron > CLEAR_TMP_DIRS AT_BOOTUP and other fine tuning parameters there also) but I am not sure that it still works since systemd.

    I had it alwyas on and never experienced any negative effects (but end-users should be teached that /tmp is not for storing things themselves with a garantee it will be there after some time).

    Of course, when you do not boot your system to often (say, once a year), the cleaning effect is not great.
    Henk van Velden

  4. #4
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,004

    Default Re: The wisdom of emptying /tmp at boot time

    Yeah you're right hcvv, the tmpfiles thing doesn't work with systemd any more - I noticed when I jumped to 13.1 myself, you now you need to use the tmp.conf method.
    .: miuku #suse @ irc.freenode.net
    :: miuku@opensuse.org

    .: h​ttps://download.opensuse.org/repositories/home:/Miuku/

  5. #5
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,935
    Blog Entries
    2

    Default Re: The wisdom of emptying /tmp at boot time

    No need to clear the tmp files anymore.

    Aside from it now being deployed as tmpfs, I think it was in the 12.3 notes(someone needs to check exactly when) the tmp directory was cleared automatically on shutdown anyway.

    TSU

  6. #6

    Default AW: Re: The wisdom of emptying /tmp at boot time

    Quote Originally Posted by tsu2 View Post
    Aside from it now being deployed as tmpfs, I think it was in the 12.3 notes(someone needs to check exactly when) the tmp directory was cleared automatically on shutdown anyway.
    That's plain wrong.

    /tmp IS NOT and NEVER WAS setup as tmpfs on openSUSE.

    And it is _not_ cleaned by default either, at least not in 13.1:
    See the shipped /usr/lib/tmpfiles.d/tmp.conf:
    Code:
    #  This file is part of systemd.
    #
    #  systemd is free software; you can redistribute it and/or modify it
    #  under the terms of the GNU Lesser General Public License as published by
    #  the Free Software Foundation; either version 2.1 of the License, or
    #  (at your option) any later version.
    
    # See tmpfiles.d(5) for details
    
    # Clear tmp directories separately, to make them easier to override
    # SUSE policy: we don't clean those directories
    d /tmp 1777 root root -
    d /var/tmp 1777 root root -
    
    # Exclude namespace mountpoints created with PrivateTmp=yes
    x /tmp/systemd-private-*
    x /var/tmp/systemd-private-*
    X /tmp/systemd-private-*/tmp
    X /var/tmp/systemd-private-*/tmp

  7. #7
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    20,193
    Blog Entries
    1

    Default Re: The wisdom of emptying /tmp at boot time

    Quote Originally Posted by tsu2 View Post
    No need to clear the tmp files anymore.

    Aside from it now being deployed as tmpfs, I think it was in the 12.3 notes(someone needs to check exactly when) the tmp directory was cleared automatically on shutdown anyway.

    TSU
    Not with openSUSE to date.

  8. #8

    Default Re: The wisdom of emptying /tmp at boot time

    Quote Originally Posted by Miuku View Post
    I think it would be a better idea to use the systemd cleaning.
    Take a peek at:
    Code:
    /usr/lib/tmpfiles.d/tmp.conf
    If you make a copy of it in /etc/tmpfiles.d/ and edit that, it'll override the defaults.
    I copied tmp.conf to /etc/tmpfile.d/ and
    Code:
    changed
    d /tmp 1777 root root -
    to
    d /tmp 1777 root root 1d
    Which, AIUI, at boot time deletes all files and dirs older than 1 day in the /tmp/ directory. If I changed the number to 0 (zero), all files and dirs would be deleted.

  9. #9
    Join Date
    Nov 2013
    Location
    Kamloops, BC, Canada
    Posts
    3,974

    Default Re: AW: Re: The wisdom of emptying /tmp at boot time

    Quote Originally Posted by wolfi323 View Post
    That's plain wrong.

    /tmp IS NOT and NEVER WAS setup as tmpfs on openSUSE.

    And it is _not_ cleaned by default either, at least not in 13.1
    ... and not in 12.1 nor 12.3, either. I doubt it ever was cleaned by default.

    BTW: /var/tmp also is not cleaned by default.
    -Gerry Makaro
    Fraser-Bell Info Tech
    Solving Tech Mysteries since the Olden Days!
    ~~
    If I helped you, consider clicking the Star at the bottom left of my post.

  10. #10

    Default Re: The wisdom of emptying /tmp at boot time

    Along the same idea, I decided to put /tmp in memory. This is simply done by adding a line to /etc/fstab:

    Code:
    tmpfs          /tmp     tmpsfs size=100m     0 0
    Every time you boot it will start empty. As an unexpected bonus, this make the entire system much faster!
    This makes sense since lots of software write to /tmp as they start or during operations and now the same
    is done purely in memory.

    The main issue you will find is size. Many software which require huge temporary files such as autopano or
    k3b, let you specify additional paths to circumvent this.

    - Itai
    - Itai
    http://www.cybernium.net

Page 1 of 6 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •