ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Anyone ever use the clrtmp utilty?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anyone ever use the clrtmp utilty?

    our /tmp directory seems to get filled up over time by various applications. I discovered the QSHELL utility clrtmp. IBM documentation said this could be added to QSTRUP.


    Anyone do this? If so, any caveats?

    I'm assuming I can simply add something like this to my QSTRUP CL program:

    CHGVAR VAR(&CMD) VALUE('clrtmp')
    STRQSH CMD(&CMD)

    Greg

  • #2
    Only serious caveat that comes quickly to mind is to be sure to run it before starting any subsystems that might have auto-starts or pre-starts that might use /tmp.
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment


    • #3
      Yeah, as it says in the docs, its important to run this when the system is not running, since any software that is relying on those objects in /tmp may otherwise malfunction.

      Also, in the Unix world, some sysadmins think that clearing /tmp is a bad idea, since some software expects the files to be maintained. For example a software that queues e-mail messages might place them there until it's able to send them. If you clear it, you'd lose those messages. Software really should NOT use /tmp for this sort of thing... but unfortunately, some do.

      I've also seen software that uses /tmp for 'recovery'. For example, if you reboot the system while editing a file, it saves a copy of the changed file in /tmp so when the system comes back, the changes aren't lost. Not sure how often that happens on IBM i, though. But, I've seen that on actual Unix systems.

      As long as you don't think there's anything there that you need, it should be fine to clear it from QSTRUP during an IPL.

      Personally, I take a different approach -- I delete things that are unmodified for 1 month. This is done when the system is taken down for regular maintenance (so I know nobody is using it) and then I just delete anything unmodified for a month... seems safer to me than just deleting everything..

      Comment


      • #4
        Thanks for the responses... I actually have a program that reads a folder and deletes objects based on the mod date (I think I copied one of your examples Scott). It currently ignores directories.

        Most of the files in this folder ARE related to email messages that failed to send. The truth is that we never try to resend any that fail... so I may as well delete them.

        But there are other objects in /tmp as well. Directories beginning with "db2jtmp_" and some things that appear to be related to the ZEND server (we are running , but not using).

        Comment


        • #5
          Sounds like a useful tool, but I've never used it. We do more or less the same thing every night before backup.

          CHGVAR VAR(&QSHCMD) VALUE('rm -rf /tmp/*')
          QSH CMD(&QSHCMD)

          Comment


          • #6
            Originally posted by jtaylor___ View Post
            Sounds like a useful tool, but I've never used it. We do more or less the same thing every night before backup.

            CHGVAR VAR(&QSHCMD) VALUE('rm -rf /tmp/*')
            QSH CMD(&QSHCMD)
            Sorry... I'm functionally illiterate when it comes to Unix commands... What exactly does that do?

            Comment


            • #7
              No worries. It removes everything under /tmp, including sub-directories.

              Comment


              • jtaylor___
                jtaylor___ commented
                Editing a comment
                Or I should say it tries to delete everything. There are usually some things that silently fail to delete.

            • #8
              I added this to our QSTRUP start-up program and have been running with it just over two years without any issues. I just added the following one command in at the beginning of the process with the comment so any subsequent admins will know what the command is.

              /* Qshell Command clrtmp - Clear the /tmp directory */
              QSH CMD('CLRTMP')

              Comment


              • #9
                Originally posted by jtaylor___ View Post
                Sounds like a useful tool, but I've never used it. We do more or less the same thing every night before backup.

                CHGVAR VAR(&QSHCMD) VALUE('rm -rf /tmp/*')
                QSH CMD(&QSHCMD)
                So I read up a little on this. What is the functionality of the "f"?

                'rm -r /tmp/*' seems to behave the same as
                'rm -rf /tmp/*'

                I like the idea of removing the subdirectories as well.

                This was very helpful:

                Last edited by gwilburn; January 23, 2017, 02:50 PM. Reason: Read a bit more...

                Comment


                • #10
                  rm -r /tmp/* will return an error if it's unable to delete something (due to lack of permissions or whatever). rm -rf /tmp* will not care, and will just keep on deleting as much as it can.

                  Of course, if the cwlling progrsam is ignoring the errors anyway, or if no errors, occur, they would seem equivalent.

                  Comment


                  • #11
                    Just a follow-up.

                    Thanks to all. This seems to be working great.

                    CHGVAR VAR(&QSHCMD) VALUE('rm -rf /tmp/*')
                    QSH CMD(&QSHCMD)

                    Comment

                    Working...
                    X