1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Quarterly delete files older than 3 months

Discussion in 'Oracle' started by bongalegre, Apr 28, 2010.

  1. bongalegre

    bongalegre New Member

    Joined:
    Apr 28, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hi Guys,

    I really hope you could help me I am just new in Oracle but my boss is forcing me to do scripting he said everything is available online. I tried to create but he said it was wrong maybe you can give me a helping hand.

    This will be my crontab entry
    #!/bin/sh
    #* * 1 1,4,7,10 * /root/bin/OLP-Cleanup.sh

    And this will be script run by OLP-Cleanup.sh
    find /root/archive -mtime +90 -exec rm {} \;

    He said this wil delete all the files in Archive?
    Any suggestions? Thanks!

    /bong
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    #* * 1 1,4,7,10 *

    Do you have any idea what that number actually mean?
     
  3. bongalegre

    bongalegre New Member

    Joined:
    Apr 28, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    My intentions is to run the script on 1st day of Jan, Apr, Jul, oct. Is it wrong?
    I got this as reference from somewhere

    at that interval.

    * * * * * command to be executed
    - - - - -
    | | | | |
    | | | | +----- day of week (0 - 6) (Sunday=0)
    | | | +------- month (1 - 12)
    | | +--------- day of month (1 - 31)
    | +----------- hour (0 - 23)
    +------------- min (0 - 59)
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    No it is right but you should specify the hour and minute if you want it to run only once.

    So now the question comes what is the issue?

    If it deletes all the files means your script contains error.
     
  5. bongalegre

    bongalegre New Member

    Joined:
    Apr 28, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    hmm actually we haven't tried this yet. based from my boss assumption he thought this may not work.
    But I demanded that this will not delete the file cause I set the run command to delete files +90 days old only.

    Just to make sure before he gets back I want to get a second opinion or if you have a better approach for the said purpose? Thanks!
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    This will make the script to run after 90 days but not sure what it will do when run is the question.
     

Share This Page