Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

TechTip: Clean Up Old IFS Files

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

  • TechTip: Clean Up Old IFS Files

    I hope you enjoyed the article.

  • #2
    TechTip: Clean Up Old IFS Files

    Interesting technique but there's another way to do this that doesn't require writing a program. You can use the QShell find command to delete files. Here's an example that delete's old PDFs more than 180 days old: find -x /pdftemp -type f -name *.pdf -mtime +180 -exec rm {} ; (you can read up on the find command by doing a Google search for "man find") Because of the way QShell works, the find command can take a long time to work for a large number of files but besides being able to delete files, you can send the file name off to other QShell commands and scripts which opens up a lot of possibilites. Matt

    Comment


    • #3
      TechTip: Clean Up Old IFS Files

      ** This thread discusses the Content article: TechTip: Clean Up Old IFS Files **
      0

      Comment


      • #4
        TechTip: Clean Up Old IFS Files

        I was looking for a way to do this w/o having to write complex API programs and have flexability of getting specific files, for example just my own etc. This gave me a chance to learn some new techniques as well. Thank you for the tip I will look into it more when I have some extra time.

        Comment


        • #5
          Re:TechTip: Clean Up Old IFS Files

          Guys, I sure would like to speak to someone about cleaning up IFS on iSeries. I have looked at this article, and some of the links no longer work. The problem I see, and not sure how the author got around it; its when performing the ls -lT command, etc. Your assuming that the output to the PF is similar to a spool file where all the fields are always in the same position for a program to read and populate variables. That is not the case... Example... If you do a ls -lT to a PF and the files are owned by someone with a 6 digit profile. Then you do it again and there is now a file that is owned by someone with a 8 digit profile. All your fields shift by 2 so, your program no longer works. Is there a way to make the output always have the same positional values? Thanks, Keith LaBorde

          Comment


          • #6
            Re:TechTip: Clean Up Old IFS Files

            We have had good luck with the QRYIFSLIB from IBM: http://www-912.ibm.com/s_dir/slkbase...3?OpenDocument Terry

            Comment


            • #7
              Re:TechTip: Clean Up Old IFS Files

              Wonderful ! This is exactly what I have been looking for. Thank You very much...

              Comment


              • #8
                Re:TechTip: Clean Up Old IFS Files

                Question concerning ifstools? CALL PGM(QRYIFSLIB) PARM('/www/iwabase/logs/*' + '\L:TBCKLB') Creating outfile qryifslib in my library. Now when I dclf in a CL program I am having problems with variable fields. Can I not use CLP and use variables for processing? Thanks, Keith

                Comment


                • #9
                  Re:TechTip: Clean Up Old IFS Files

                  We defined a separate file with fixed length fields to store the output of QRYIFSLIB to eliminate the hassle of using variable length fields. Here's the DDS - remember to change the DIRNAME and FIELDNAME lengths if you want them longer. We use 100 bytes because our IFS folder levels aren't very deep. R MYRECD DIRNAME 100 COLHDG('Directory' 'Name') FILENAME 100 COLHDG('File' 'Name') ST_MODE 9 COLHDG('Mode') ST_SIZE 18S 0 COLHDG('File' 'Size') ST_ATIME 26 COLHDG('Access' 'Date') ST_MTIME 26 COLHDG('Change' 'Date') ST_CTIME 26 COLHDG('Status' 'Date') ST_BLKSIZE 9S 0 COLHDG('Block' 'Size') ST_ALLOCSZ 18S 0 COLHDG('Allocated' 'Size') ST_OBJTYPE 11 COLHDG('Object' 'Type') ST_UID 10 COLHDG('UID') ST_GID 10 COLHDG('GID') K FILENAME After you make the call to QRYIFSLIB, use a CPYF to place the output in your new file: CPYF FROMFILE(QTEMP/QRYIFSLIB) + TOFILE(MYLIB/MYFILE) MBROPT(*REPLACE) + FMTOPT(*MAP *DROP) Hit me up offline and I'll send you a CL program, DDS for the physical and a Cobol program that deletes entries over X days old... This is my second posting attempt...apparently the "preview" capability goes into never-never land... Terry

                  Comment


                  • #10
                    Re:TechTip: Clean Up Old IFS Files

                    Thanks Terry for the assistance in helping me get this up and running. I was just doing the DDS when I see you used the same approach as what I was going to try next. Due to time constraints, my management wants me to implement the QTXTSRC method, and a batch job using IBM Scheduler. We will add multiple entries to the record for those directories we want to clean up. STRQSH CMD('qsys.lib/itools.lib/qtxtsrc.file/ifscln.mbr') For testing... I created this ifscln entry in itools/qtxtsrc. find /tbcklb/*.* -mtime +10 -exec rm -d {} ';' I was getting an error originally that the ; was missing. But when I added the ticks in the source file, it worked correctly. I do see test files got cleaned up when I ran the job. My other problem is.... I have a few files that are old that are not being deleted. I am not the owner of these files. I wonder if this is an authority issue? Where can I look to see a job log? The job in the IBM Scheduler is using a profile with *ALLOBJ by the way. Does anyone have any ideas. Thanks, Keith

                    Comment


                    • #11
                      Re:TechTip: Clean Up Old IFS Files

                      klaborde wrote:
                      My other problem is.... I have a few files that are old that are not being deleted. I am not the owner of these files. I wonder if this is an authority issue?
                      I suspect your correct - it may be related to authority. If you have OpsNav running you or someone who has higher authority could check the permissions on the files to confirm... Terry

                      Comment


                      • #12
                        Re:TechTip: Clean Up Old IFS Files

                        Guys, Well I think I am getting close to what I am trying to do. I have one issue concerning directories that I need to resolve. In an earlier post I mentioned I was using the following entries in QTXTSRC, and using the IBM Scheduler to submit the job to Qshell. The results are, the IFS files did get removed, but the directories within were not touched. My solution for now was to do the following. *************** Beginning of data ************************ # # Delete files in /TBCKLB > 1 days. find /tbcklb/*.* -mtime +1 -exec rm -d {} ';' find /tbcklb/direc/*.* -mtime +1 -exec rm -d {} ';' find /tbcklb/save/*.* -mtime +1 -exec rm -d {} ';' # ****************** End of data *************************** I thought the rm -d parm did the following as stated in the IBM Qshell RedBook. I did try the -R, with no success. If I have to have an entry for each directory, I can live with that, but was wondering why it would not go to the next level? Has anyone got around this? Options -d Attempt to remove directories as well as other types of files. -f Attempt to remove the files without prompting for confirmation, regardless of the file’s permissions. If the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error. The -f option overrides any previous -i options. -i Request confirmation before attempting to remove each file, regardless of the file’s permissions, or whether or not the standard input device is a terminal. If the response from the standard input begins with the first character for the YES response in the current locale, the file is removed. The -i option overrides any previous -f options. -P Overwrite regular files before deleting them. Files are overwritten three times, first with the byte pattern 0xff, then 0x00, and then 0xff again, before they are deleted. -R Attempt to remove the file hierarchy rooted in each file argument. The -R option implies the -d option. If the -i option is specified, the user is prompted for confirmation before each directory’s contents are processed (as well as before the attempt is made to remove the directory). If the user does not respond affirmatively, the file hierarchy rooted in that directory is skipped. -r Equivalent to -R. Thanks, Keith

                        Comment


                        • #13
                          Re:TechTip: Clean Up Old IFS Files

                          Question... CALL PGM(QRYIFSLIB) PARM('/www/iwabase/logs/*' '\L:TBCKLB') I want to pass variables for the two parms above. It looks like the QRYIFSLIB program wants to see the ticks? How do I delare variables say &parm1 &parm2 to include the ticks inside the variable? Thanks, Keith

                          Comment


                          • #14
                            Re:TechTip: Clean Up Old IFS Files

                            Keith, You need to make sure that your string variables contain a trailing null value:
                            Code:
                             DCL VAR(&NULL) TYPE(*CHAR) LEN(01) VALUE(X'00') DCL VAR(&PATH) TYPE(*CHAR) LEN(51) DCL VAR(&LIB) TYPE(*CHAR) LEN(14) CHGVAR VAR(&FOLDER) VALUE('/Engraver/*') CHGVAR VAR(&PATH) VALUE(&FOLDER *TCAT &NULL) CHGVAR VAR(&LIB) VALUE('\L:QTEMP' *CAT &NULL) CALL PGM(QRYIFSLIB) PARM(&PATH '\S' '\Q' '\T' + &LIB)
                            Terry

                            Comment

                            Working...
                            X