Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: delete all that is inside the /tmp folder

  1. #1

    Default delete all that is inside the /tmp folder

    Hello

    I would like to know if a problem will occur if I delete everything inside the /tmp folder

    Thank you so much

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,739

    Default Re: delete all that is inside the /tmp folder

    It depends on when itis done. When the system is running and people are loged in, files that are in use could be deleted .

    When you want to keep a clean /tmp, there are a few ways to do this.

    =================================
    For cleaning /tmp and /var/tmp at boot:

    When there is not already a file /etc/tmpfiles.d/tmp.conf create it as a copy

    Code:
    cp /usr/lib/tmpfiles.d/tmp.conf /etc/tmpfiles.d/tmp.conf
    Then change the lines
    Code:
    # 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 -
    into
    Code:
    # Clear tmp directories separately, to make them easier to override
    # My policy: empty /tmp en /var/tmp.
    D /tmp 1777 root root 1d
    D /var/tmp 1777 root root 1d
    See
    Code:
    man 5 tmpfiles.d
    ==================================
    Another way to do this is to make /tmp a separate file system of type tmpfs.
    Code:
    tmpfs        /tmp    tmpfs    size=25%,uid=root,gid=root,mode=1777 0 0
    The file system will be destroyed on shutdown and thus be emptied.
    See
    Code:
    man 8 mount
    specially the section: Mount options for tmpfs
    Last edited by hcvv; 31-Jan-2018 at 04:10.
    Henk van Velden

  3. #3

    Default Re: delete all that is inside the /tmp folder

    Normally not.

    Unless you use /tmp for storing important files of course...
    There were large outcries from some users when suddenly /tmp was cleaned automatically in some 12.x version, it got disabled by default again because of that.

    So maybe check at least if there are important files, some applications may be configured to use /tmp for "important" stuff e.g.
    Last edited by wolfi323; 31-Jan-2018 at 04:10.

  4. #4

    Default Re: delete all that is inside the /tmp folder

    Quote Originally Posted by hcvv View Post
    When the system is running and people are loged in, files that are in use could be deleted .
    Files that are in use won't get deleted really.
    They will only be removed from the directory, the data will still be kept (as long as applications have the files open at least).

    That's not to say that some applications might not get confused or something (e.g. an application could close the file and then expect to be able to open it again, which would not be the case because it got deleted meanwhile).
    Last edited by wolfi323; 31-Jan-2018 at 04:14.

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,739

    Default Re: delete all that is inside the /tmp folder

    Quote Originally Posted by wolfi323 View Post
    Files that are in use won't get deleted really.
    They will only be removed from the directory, the data will still be kept (as long as applications have the files open at least).

    That's not to say that some applications might not get confused or something (e.g. an application could close the file and then expect to be able to open it again, which would not be the case because it got deleted meanwhile).
    Sometimes a short warning which gives a hint to what might go wrong is better IMHO then explaining until the last bit. And your last remark is covered by my expression "in use", just an english expression, not to be confused with the technical term "opened file".
    Henk van Velden

  6. #6

    Default Re: delete all that is inside the /tmp folder

    Quote Originally Posted by hcvv View Post
    Sometimes a short warning which gives a hint to what might go wrong is better IMHO then explaining until the last bit.
    Ok, but I only did this in reply to you.

    Still, there should not be problems.
    And in any case nothing that a reboot wouldn't solve.

  7. #7

    Default Re: delete all that is inside the /tmp folder

    PS: your sugested change will have the same theoretical "problem":
    Quote Originally Posted by hcvv View Post
    Then change the lines
    Code:
    # 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 -
    into
    Code:
    # Clear tmp directories separately, to make them easier to override
    # My policy: empty /tmp en /var/tmp.
    D /tmp 1777 root root 1d
    D /var/tmp 1777 root root 1d
    As it may delete the files while the system and applications are running.

  8. #8
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,739

    Default Re: delete all that is inside the /tmp folder

    Quote Originally Posted by wolfi323 View Post
    Ok, but I only did this in reply to you.
    I am fully aware on how Unix/Linux keeps count of the proceses that have a file open since about 40 years.
    Quote Originally Posted by wolfi323 View Post
    Still, there should not be problems.
    And in any case nothing that a reboot wouldn't solve.
    Well, having to reboot a system after a user encounters a failing application is a problem IMO.
    Not only would it be reported as a problem, but the root cause would then be nailed down on a blundering system manager.
    Henk van Velden

  9. #9

    Default Re: delete all that is inside the /tmp folder

    Quote Originally Posted by hcvv View Post
    I am fully aware on how Unix/Linux keeps count of the proceses that have a file open since about 40 years.
    Ok, fine.
    But then you have to admit that your statement was not fully correct...

    Well, having to reboot a system after a user encounters a failing application is a problem IMO.
    Not only would it be reported as a problem, but the root cause would then be nailed down on a blundering system manager.
    It's only a theoretical problem, and it would indeed be a bug (in the corresponding application) IMHO.

    Also, a restart of the affected application should help anyway, a reboot would just make that implicit.

    And as mentioned, your suggested way to automatically delete files has the same problem, but then it may happen randomly and not at the point the user/administrator decides explicitly to delete the files in /tmp.

    But whatever.
    I see no point in continuing this discussion really.

  10. #10
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,739

    Default Re: delete all that is inside the /tmp folder

    Quote Originally Posted by wolfi323 View Post
    And as mentioned, your suggested way to automatically delete files has the same problem, but then it may happen randomly and not at the point the user/administrator decides explicitly to delete the files in /tmp.
    When I read
    Code:
    man 8 tmpfiles.d
    I get the strong impression that this happens at boot and not randomly.

    As I see it, it is the way systemd implements the cleaning of /tmp at boot (an old feature of many Unix/Lunux versions). This cleaning of /tmp is part of a wider implementation of "Configuration for creation, deletion and cleaning of volatile and temporary files" (as so many things im systemd try to cover everything).
    Henk van Velden

Page 1 of 2 12 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
  •