The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Simpre Cron job problem

Discussion in 'General Discussion' started by webstyler, Feb 14, 2004.

  1. webstyler

    webstyler Well-Known Member

    Joined:
    Nov 20, 2003
    Messages:
    432
    Likes Received:
    0
    Trophy Points:
    16
    I have this :

    find /home/mysite/public_html/download -type d -cmin +20 -exec rm -rf {} \;

    This beacause I want delete all dir and files "INTO" dir download that is old more 20 minutes

    BUT the problem is that this delete also dir download ??

    :confused:

    why ?

    thks
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Change the find to:

    find /home/mysite/public_html/download/* -type d -cmin +20 -exec rm -rf {} \;
     
  3. webstyler

    webstyler Well-Known Member

    Joined:
    Nov 20, 2003
    Messages:
    432
    Likes Received:
    0
    Trophy Points:
    16
    :D Perfect

    But I receive this in email :

    find: /home/flextic/public_html/client_download/*: No such file or directory
     
  4. nickn

    nickn Well-Known Member
    PartnerNOC

    Joined:
    Jun 15, 2003
    Messages:
    619
    Likes Received:
    1
    Trophy Points:
    18
    Crontab this :

    Code:
    cd /home/mysite/public_html/download; find . ! -name . -cmin +20 -exec rm -rf {} ';' > /dev/nul 2>&1
    
    You don't want to delete the directory itself, so you need to tell it that, also if you want to delete directories and files, you'll need to remove the type attribute or put two different crontabs in there, one for files and one for types (-type f for file, -type d for directories)
     
Loading...

Share This Page