ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to clear a folder...

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

  • How to clear a folder...

    Okay here's my situation .... I have a folder on the IFS called RVITEMP that our imaging software (RVI - Real Vision Software) created and they use as a temporary storage folder when they are converting the TIFF images to PDF's. The folder has to be near if not exceeding the storage capacity because I can't even open it up to look at or see what is inside of the folder. I've tried to open using iSeries navigator, I've tried from the 400 - wrkflr and wrklnk ... nothing works.

    So I contacted RVI and they said there was nothing in there that we will need and its okay to clear the folder. I was told this: There?s nothing in place currently to clear that directory. A unix type command can do the trick:

    DEL ?/RVITEMP/*?

    So I created a QSH command in a CL program using the above string and the system doesn't like that.

    So my question is .... how the heck do I clear the bugger????

    Thanks
    Roxann

  • #2
    Re: How to clear a folder...

    Hmmm... what about going into Qshell and doing something like rm -rf /rvitemp/*

    Double check that though because I think it zaps the files and any sub-folders (r = recursive) and I dont have the rm man page handy.

    -John Andersen
    Introducing The IBM i and AS/400 Training That 100% Guarantees You Will Learn Key Administration Tasks...

    Comment


    • #3
      Re: How to clear a folder...

      If what John says does not work, maybe you could delete the folder, then re-create it afterwards.
      Regards

      Kit
      http://www.ecofitonline.com
      DeskfIT - ChangefIT - XrefIT
      ___________________________________
      There are only 3 kinds of people -
      Those that can count and those that can't.

      Comment


      • #4
        Re: How to clear a folder...

        I just changed my progam after reading up to make sure John' suggestion was usable. I changed it to rm -r /RVITEMP and the program is running now. I'll let you know how it goes.

        Thanks for the help!

        Roxie

        Comment


        • #5
          Re: How to clear a folder...

          Originally posted by NYCountryGal
          A unix type command can do the trick:

          DEL ‘/RVITEMP/*’
          FWIW... "DEL" is not a Unix command. It's a native CL command. (Actually, it's an alias for RMVLNK. RMVLNK and DEL are the same command.) It would be:

          Code:
          DEL OBJLNK('/RVITEMP/*')
          Like I said.. that's a regular CL command. You run it at the "normal" command line (or within a CL program) you don't run it in QShell.

          Code:
          DEL '/RVITEMP/*'
          The QShell version is rm (as John has already said.) One advantage to the QShell variant is that it's able to delete subdirectories inside of the main directory. (Whereas, DEL/RMVLNK can delete all of the files in a folder, but won't go into subdirectories within them.) But, it doesn't sound like that is needed here? If that's not needed/desired, then I'd remove the -r option from rm, just to be safe.

          Also, I don't understand why John suggested the -f option to rm. That option tells it to ignore any errors... is that really what you want?

          So, if you go the QShell route, I would do:

          Code:
          QSH CMD('rm /rvitemp/*')
          Unless you specifically want to delete all subdirectories within the main directory (and all fo the subdirectory contents) too. In that case, do:

          Code:
          QSH CMD('rm -r /rvitemp/*')

          Comment


          • #6
            Re: How to clear a folder...

            Before wholesale clearing you could dump the contents;

            CRTPF LibName/FileName RCDLEN(132)

            STRQSH

            ls -l /RVITEMP/ > QSYS.LIB/LibName.LIB/FileName.FILE/FileName.MBR

            <F3> to exit QSH.

            Check the output file listing, if the first char is a "d" then it is a directory, if it's a "-" then it's a file.

            It's the weekend and I'm outa here but I am sure there is a clever way to "recurse" this so it puts the sub folders into the ls command to get it all in one pass.

            But the contents may help you narrow down the rm commands rather than being all clearing.
            Try whacking that in a CL so it can run in batch if the folder is large.

            Try it on a test folder first ... good luck
            Greg Craill: "Life's hard - Get a helmet !!"

            Comment


            • #7
              Re: How to clear a folder...

              Originally posted by gcraill View Post
              It's the weekend and I'm outa here but I am sure there is a clever way to "recurse" this so it puts the sub folders into the ls command to get it all in one pass.
              Using ls, you would add an 'R' to make it recurse. ex: ls -lR /RVITEMP/, etc.

              However, the code to properly interpret the recursive 'ls' output is not trivial. Instead, may I suggest using the 'find' tool if you wish a recursive list?

              find /RVITEMP

              Should list all files within /RVITEMP, recursively, with full pathnames. Much easier to read from a program. If you need the permissions, sizes, dates, etc of the files, you could add the -ls switch to find.

              find /RVITEMP -ls

              Find can do a lot of other useful things, such as give you files that haven't been used in 30 days, or files that are owned by a given userid, etc.

              Also, please remember that each component of an IFS path name can be as large as 256 characters. /256chardirname/256chardirname/256charfilename, etc. So an IFS directory name can be extremely large. It's rather unusual for that size to exceed a few kilobytes (though, technically, it could be as large as 16mb) but exceeding 132 characters is extremely common. I would not make your PF record be only 132 long.

              In fact, unless you have a good reason to use a PF, I would suggest using a stream file. That way, record length is a non-issue, and it doesn't use as much disk space, either. A STMF will also work more nicely with QShell/PASE tools than a PF will. But, on the flip side, the advantage to a PF would be that it works better with CL. So, those are the pros/cons, I guess.

              I would have said all of this before, but, it didn't sound like NYCountryGal really needed this based on her original post. It sounded like she knew what the files were, and knew she wanted to zap them all.

              Comment


              • #8
                Re: How to clear a folder...

                Hi All ---

                I wanted to update you and let you know what happened! It's good news...

                First though - Scott thank you for the information. I've only used QSH a few times here and there so I'm learning - so far I haven't taken down the system with anything I've done. I took John's advice and researched a little before running the command. I went with the last example you have in your first post - although I did leave off the /* after doing my research.

                At gcraill - I didn't care about listing the contents - as soon as RVI told me they didn't use the file for anything other then garbage - it was let's clear the puppy out. But thanks for the information -- it may come in handdy down te road.

                Okay - ready -- I submitted the QSH job at noon on Tuesday - the ASP% on our system was 86.xxxx%. Our disk space report showed we were at 99.84% -- when I left at 7 PM - the ASP% was down to 80% my manager called me at home the next morning and said - What did you do? Huh? - rut ro... We're down to 41% and its still falling! HOLY S*it!!! Holy S*it Holy S*it I hit pay dirt ... this is the cleanest our system has been since I started here six years ago!!!

                The job ran for 27 hours!!! And we're at 31% ASP!! I was doing my happy dance and I still am!!

                So -- for all of you that use Real Vision Software for your document imaging system -- there is a folder on your IFS called RVITEMP. RVI does not have any programs to clear this folder out -- they don't even think to tell you to keep this folder clean. Do yourselves a favor and use the clear command above and get yor space back!

                Three years ago - this company went out and bought more disk space because we were chewing it up. Little did we know that we had this folder and it was eating up our space! RVI has been on this system since 2005 and that folder had never been cleared out in all that time. Never - not once.

                I'm so glad I started poking around looked and folders and asked - Hey what's this and what is it used for?

                Thanks for all the input!! And you all have yourselves a fantastic afternoon!!! I'm a grinnin ....

                Roxie

                Comment


                • #9
                  Re: How to clear a folder...

                  We go way back...There was a scheduled job that nuked the rvitemp daily. Guess it was gone.
                  Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                  Comment


                  • #10
                    Re: How to clear a folder...

                    @DeadMan - Are you serious? There is nothing in the job scheduler entries to clear that folder and I found nothing in any of the clean up programs. When Steve could finally get into the folder yesterday morning it was only just then starting on junk from 2012 and there were 40,000+ objects out there to delete. And that clear job had to have been removed prior to your leaving because we were having space issues only a few months after you left, but I wasn't being as thorough of a detective as I am now. And you've answered a question we had - should it be run daily? I'll get it set up so that it does.

                    Thanks for responding ....

                    Comment


                    • #11
                      Re: How to clear a folder...

                      Whoa... Are you serious? 55% of your ASP was taken up with leftovers that you don't use? That's nuts.

                      I suspect that there's a period of time where the data in RVITEMP is still relevant. It might be smart NOT to delete all of the stuff in the directory each day, because there might be a window during which it'll interfere with your processing. Perhaps it'd be wise to save stuff until it's 1 day old, or something like that?

                      This can be done easily with the 'find' command in QShell.

                      Code:
                      STRQSH CMD('find /RVITEMP -type f -mtime +1 | xargs rm')
                      This deletes all files in /RVITEMP that have not been modified in the past day. Should be easy enough to throw into a CL program and run on a job scheduler or something.

                      Comment


                      • #12
                        Re: How to clear a folder...

                        @NyCountryGal,
                        another tip to find all object eating up your systems disk space:
                        RTVDSKINF ... submit that to batch and wait until it completes. After that issue PRTDSKINF and you will get a complete listing of all containers (libraries, FLRs, IFS paths and system objects) sorted by size.

                        Just prompt the command PRTDSKINF and see what options you have to start your analysis.
                        Sven

                        The best way to prove your knowledge is to share it ...

                        Comment


                        • #13
                          Re: How to clear a folder...

                          I knew there was a clever way to do this - thanks Scott!
                          Greg Craill: "Life's hard - Get a helmet !!"

                          Comment

                          Working...
                          X