5 Replies
      Latest reply: Feb 20, 2017 2:45 AM by iPad_dev RSS
      ocworld Level 1 Level 1 (0 points)

        When "/tmp" and $TMPDIR directory are cleaned up in macOS?


        I know about removing files and directories in /tmp directory in boot time. Is it right?


        In addition, are there other times in trying to clean up the directory?

        • Re: When "/tmp" and $TMPDIR directory are cleaned up in macOS?
          eskimo Apple Staff Apple Staff (7,960 points)

          Why do you care?  Specifically, are you asking from an API perspective (as a developer, when is it safe to leave files in the temporary directory?) or from a user perspective (when will the system recover that disk space?).

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: When "/tmp" and $TMPDIR directory are cleaned up in macOS?
              ocworld Level 1 Level 1 (0 points)

              My app creates and check some files in "/tmp" or $TMPDIR.

               

              It's because files tried to be saved in user selective path are stored temporary and because some files to be used flags whether my app logs its status or not. To protect human error, for example, our supporter team's forgetting removing a log flag file, there files stores in /tmp or $TMPDIR

               

              So, for app's operations and maintenace, I wanna know the time.

               

              If only every boot time, I'm OK. But not, there are somethings to be considered such as safer code and explaining these things to techincal support team and testers who want to log my app status long time.

                • Re: When "/tmp" and $TMPDIR directory are cleaned up in macOS?
                  eskimo Apple Staff Apple Staff (7,960 points)

                  Thanks for the explanation.

                  The temporary directory cleanup is actually run by infrastructure inherited from BSD.  You can read about it in the periodic.conf man page and by reading /etc/periodic/daily/110.clean-tmps and /etc/defaults/periodic.conf.  It looks like daily_clean_tmps_days defaults to 3, meaning that a file gets deleted if it hasn’t been accessed in three days.

                  Keep in mind that the specific details aren’t considered API, and can vary from release to release and platform to platform.  For example, iOS has a very different system for handling temporary files.

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"

              • Re: When "/tmp" and $TMPDIR directory are cleaned up in macOS?
                iPad_dev Level 2 Level 2 (25 points)

                they get cleaned along with a lot of other crap every time i run my bash script,   sudo nuke garbage

                 

                1 cleans out the internet cache,

                2 rebuild the mail database, delete downloaded just

                3 nukes every .DS_Store  on any drive

                4. nukes every .Trash on every drive

                 

                you should just download Onyx, Maintenance or Deeper