delete old IFS files

2555 pts.
Tags:
IFS Commands
STRQSH
System i
I have been asked to create an automatic procedure which cleans out (ie delete) files older than 6 months. Transactionfiles keep coming into the system, and after having been processed (read) they are moved to an IFS directory 'archive'. We now have more than 90.000 files from last 26 months. I have considered various solutions like 'ls' to a file, and then read via pgm and execute delete, BUT something tells me that there is a better solution. I would like to do the job from a CL-pgm using STRQSH with some 'rm' command, but I got stuck in my investigations. Pls give me some thoughts on how to do this smart.

Software/Hardware used:
system i, v6r4

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

You can try to check out this link.
<a href=”http://www.mcpressonline.com/programming/rpg/tips-and-techniques-delete-old-spool-files.html”>

Good luck,
YuVa47

Discuss This Question: 10  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • NullFields
    If you have TAATOOLS, that has a couple options for deleting old files in an IFS directory
    880 pointsBadges:
    report
  • DanTheDane
    After a lot of investigation, I got created the one-statement-solution to my question. Since no one amongst you seems to know what I found out, I'll teach you the trick. If you insert the directory-path of the directory to search/delete old files into the following CL-statement the command will do the job of deleting fils older than 180 days.
    STRQSH CMD('find [mydirpath] -type f -mtime +180 | xargs rm')
    
    In short: the QSHELL command 'find' creates an internal list of files older than 180 days; - the lst is 'piped' (passed) to the delete-function ('xargs rm'). Of course the 180-number may be changed to other values. Yet another proof tht we are working on a great machine - it also runs unix-commands :-) PS: Some may prefer two lines of code:
    CD [mydirpath]
    STRQSH CMD('find . -type f -mtime +180 | xargs rm')
    
    best rgds DanF
    2,555 pointsBadges:
    report
  • DanTheDane
    ...for some reason my one-line solution got lost in the prev entry; - here it is again:
    STRQSH CMD(’find [mydirpath]  -type f -mtime +180 | xargs rm’)
    
    2,555 pointsBadges:
    report
  • DanTheDane
    well... here it is with no use of the editorscode/code function: STRQSH CMD(’find [mydirpath] -type f -mtime +180 | xargs rm’)
    2,555 pointsBadges:
    report
  • Miker
    when I use the below line in CL: STRQSH CMD('find /MRTEST -type f -mtime +30 | xargs rm') I get the folowwing error when I run it: find: 001-2187 The option -TYPE is not valid.
    10 pointsBadges:
    report
  • DanTheDane
    Miker, I tried to copy/paste your statement onto a 5250 commandline; the beginning and ending apostrophes were displayed as a dark rectangle; - this made me wonder about codepage !!! Well, having replaced your directory ('/MRTEST') with a directory that exists on my box, and replaced the two errorneous rectangle characters (x'1A') with apostrophes, and removed the piping of data ('| xargs rm'), the statement looked like this:
    STRQSH CMD('find /wpa/ARKIV/WPA2ERP -type f -mtime +30')
    
    I pressed the Enter key, and the stement was executed without errors. Without the piping of the data, the data is simply displayed on screen. I have no exact answer to your question, but maybe the following could be investigated: 1. os400 release level and ptf-level. 2. is your apostrophs the right character ?? study this carefully: Your statement copy/pasted:
    STRQSH CMD(’find /MRTEST -type f -mtime +30 | xargs rm’)
    
    ..and the same code with an extra apostroph addet to the last apostroph of yours:
    STRQSH CMD(’find /MRTEST -type f -mtime +30 | xargs rm’')
    
    I copy/pasted directly in browserenvironment. Look carefully, - your apostroph and the one I entered are not the same... 3. How did you enter the statements? - on a PC with copy/paste to 5250... try keying in the statement directly on a 5250 commandline. Pls report back, and I'll try to help you. DanF
    2,555 pointsBadges:
    report
  • DanTheDane
    Sorry, - the editor changed th look of my apostroph next to your ditto. Here it is again : STRQSH CMD(’find /MRTEST -type f -mtime +30 | xargs rm’')
    2,555 pointsBadges:
    report
  • TomLiotta
    find: 001-2187 The option -TYPE is not valid. What is your OS version? What is your cume PTF level? If you run the same utility from a QSH command line, does the same error occur? (Copy/paste it if possible.) Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    Whenever working with multiple systems (different browsers, different PCs, copy/paste into emulators, any combination), things like quote marks can be a pain. See the Wiki article on Quotation mark glyphs for background. 'Smart' quotes? Yeah, right. Tom
    125,585 pointsBadges:
    report
  • bvining
    It appears that you have a very nice solution and I just wanted to point out that you could also perform the deletion using various APIs called by an application program. The application program could then also provide audit reports, "make decisions" based on varous attributes of the file, etc. A series of articles on this can be found here.
    6,475 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following