AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
Expand all | Collapse all

Why -mtime +days -exec rm result differently on local directoy and NFS dir?

  • 1.  Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Mon June 04, 2007 12:45 PM

    Originally posted by: SystemAdmin


    I run following by a script in the early morning
    find data -name 'expBaan*.*' -mtime +7 -exec rm {} \;
    find /remote/solar/flash_recovery/BAAN/data -name 'expBaan*.*' -mtime +7 -exec rm -f {} \;
    The machine is an AIX 5.3L. The data folder is a local directory; while /remote/solar/flash_recovery/BAAN/data is a NFS of this box pointing to a directory on a SUN solaris 8 box. Although the "rm" remove the file (expBaan*.) older than 7 days, there is always 8 days expBaan.* files left in that NFS directory. Why? The date on both AIX and solaris are same.
    #AIX-Forum


  • 2.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Tue June 05, 2007 12:28 PM

    Originally posted by: SystemAdmin


    what does find give you when you just do a simple find /dir -ls
    #AIX-Forum


  • 3.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Tue June 05, 2007 12:28 PM

    Originally posted by: SystemAdmin


    what does find give you when you just do a simple "find data -name 'expBaan*.*' -mtime +7 -ls"
    #AIX-Forum


  • 4.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Wed June 06, 2007 05:20 PM

    Originally posted by: SystemAdmin


    "find data -name 'expBaan*.*' -mtime +7 -ls"
    return none. But
    "find /remote/solar/flash_recovery/BAAN/data -name 'expBaan*.*' -mtime +7 -ls"
    return the one file, which is one older than 7 days. /remote/solar/flash_recovery is the NFS, that is physically located on a Solaris 8 box. With "find /remote/solar/flash_recovery/BAAN/data -name 'expBaan*.*' -mtime +7 -exec rm -f {} \;", there are always 8 files.
    #AIX-Forum


  • 5.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Wed June 06, 2007 06:04 PM

    Originally posted by: SystemAdmin


    sorry,

    I don't think I really follow your question.

    What are you exactly trying to do?
    #AIX-Forum


  • 6.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Wed June 13, 2007 10:13 AM

    Originally posted by: SystemAdmin


    i tried to remove any file older than 7 days under a NFS directory. However, I always got 8 days file left, not 7 days file, with my script. The similar script works perfectly well on a local drive, ie. 7 days file left.

    find data -name 'expBaan*.*' -mtime +7 -exec rm {} \; ## local dir
    find /remote/solar/flash_recovery/BAAN/data -name 'expBaan*.*' -mtime +7 -exec rm -f {} \; ## NFS dir
    #AIX-Forum


  • 7.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Thu June 14, 2007 08:15 AM

    Originally posted by: SystemAdmin


    Try adding, -fstype nfs to your NFS and see if that helps...
    #AIX-Forum


  • 8.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Thu June 14, 2007 09:44 AM

    Originally posted by: SystemAdmin


    I do not quite follow your suggestion. How can i add the -fstype to my nfs? is the "-fstype" an option? I did not see it in mknfsmnt.
    #AIX-Forum


  • 9.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Thu June 14, 2007 12:21 PM

    Originally posted by: SystemAdmin


    I understood what you meant after re-examining the find manual. add "-fstype nfs" after the +mtime. It seems working. I will recheck tomorrorw after the cron job. Thanks.
    #AIX-Forum


  • 10.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Fri June 15, 2007 09:07 AM

    Originally posted by: SystemAdmin


    find /remote/solar/flash_recovery/BAAN/data -name 'expBaan*.*' -mtime +7 -fstype nfs -exec rm -f {} \;
    worked when run it manually, but in the cron job to remove any file older 7 days.

    #AIX-Forum


  • 11.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Fri June 15, 2007 09:09 AM

    Originally posted by: SystemAdmin


    sorry mistypo, it should say "not working when run it in cron job".
    #AIX-Forum


  • 12.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Fri June 15, 2007 08:18 PM

    Originally posted by: SystemAdmin


    Create a file called, "script.sh"
    and place this in the file

    #!/bin/ksh -x
    find /remote/solar/flash_recovery/BAAN/data -name 'expBaan*.*' -mtime +7 -fstype nfs -exec rm -f {} \;
    exit 0

    Then use "script.sh" in your cron entry. See what happens.

    #AIX-Forum


  • 13.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Tue June 19, 2007 11:07 AM

    Originally posted by: SystemAdmin


    Well. it worked in an independent script file with your suggestion. I run it in cront job. So the only thing I missed in my original file is the first line "#!/bin/ksh -x". what does it mean?
    #AIX-Forum


  • 14.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Wed June 20, 2007 07:43 AM

    Originally posted by: SystemAdmin


    ksh -x means verbose option, you can disable it by removing the '-x'

    HTH
    #AIX-Forum


  • 15.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Thu June 21, 2007 10:17 AM

    Originally posted by: SystemAdmin


    Although the independent script that only contains that line and #!/bin/ksh -x works, then I included the #!/bin/ksh -x in my original script, it did not function still.

    #AIX-Forum


  • 16.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Thu June 21, 2007 01:17 PM

    Originally posted by: SystemAdmin


    there could be something wrong with your script.

    Try pasting it here, I can try helping
    #AIX-Forum


  • 17.  Re: Why -mtime +days -exec rm result differently on local directoy and NFS dir?

    Posted Thu June 21, 2007 06:36 PM

    Originally posted by: SystemAdmin


    Here is the script:
    #!/bin/ksh -x
    1. Subject: Run a oracle Export dump and backup to a tape
    cd /oraPump/backup

    echo "********** Oracle DB Backup starts at "$(date) >> log/BaanExpdp.log
    1. a full schema
    2. expdp baandb/##### directory=data_pump_baandb dumpfile=expBaan.dmp logfile=expBaan.log
    expdp baandb/bbaann05 parfile=baan201610.par

    grep " GB" expBaan201.log | sed "s/using BLOCKS method:/database size on $(date +'%d-%m-%Y') /" >> log/BaanExpdp.log

    grep "estimation" expBaan201.log | sed "s/Total estimation using BLOCKS method:/$(date +'%d-%m-%Y') /" >> log/sizeDB.log

    for i in expBaan*.*;
    do mv ${i} ${i}$(date +%Y%m%d%H%M)
    done

    1. ls expBaan*.* | cpio -ovC512 >/dev/rmt0.1
    tar -cvf /dev/rmt0.1 exp*.* >> log/BaanExpdp.log 2>&1

    find data -name 'expBaan*.*' -mtime +7 -exec rm {} \;
    find /remote/solar/flash_recovery/BAAN/data -name 'expBaan*.*' -mtime +7 -fstype nfs -exec rm -f {} \;
    echo "Backup ends at "$(date) >> log/BaanExpdp.log
    1. Adios!

    #AIX-Forum