Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    439
    Likes Received:
    0
    Trophy Points:
    166
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,470
    Likes Received:
    21
    Trophy Points:
    463
    Location:
    Go on, have a guess
    Change the find to:

    find /home/mysite/public_html/download/* -type d -cmin +20 -exec rm -rf {} \;
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. webstyler

    webstyler Well-Known Member

    Joined:
    Nov 20, 2003
    Messages:
    439
    Likes Received:
    0
    Trophy Points:
    166
    :D Perfect

    But I receive this in email :

    find: /home/flextic/public_html/client_download/*: No such file or directory
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. nickn

    nickn Well-Known Member
    PartnerNOC

    Joined:
    Jun 15, 2003
    Messages:
    619
    Likes Received:
    1
    Trophy Points:
    168
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice