1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Delete All Files in A Directory via cPanel Cron Job

Discussion in 'PHP' started by a4tech, Apr 11, 2013.

  1. #1
    Delete All Files in A Directory via cPanel Cron Job

    Hello, I have a directory with in website path is like that

    /home/cpanel-user/public_html/temp/garbage

    I have WHM/cPanel. Is there any way that it automatically delete all files with in garbage every hour automatically via corn.
     
    a4tech, Apr 11, 2013 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Enter this as the cron command:
    
    rm -rf /home/cpanel-user/public_html/temp/garbage/
    
    Code (markup):
     
    nico_swd, Apr 11, 2013 IP
  3. Tron8888

    Tron8888 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    I have a HostGator account and that command does not work. For me the following worked:

    find /home/<USER NAME>/then/add/folders/.Trash/cur -mtime +1 -execdir /bin/rm {} \+

    Replace <USER NAME> with the user name on the account. I'm not cron expert but do understand code concepts. All I know is I tried a dozen ways using a simple cron command (don't have SSH access) to delete the emails from the trash folders for the many accounts and email boxes I have. This seemed to work best without writing fancier scripts that loop to find the .trash folders and delete files. For me it's not that bad to add this cron job to each account and have run once a day instead of having to log into Webmail and force the trash folder delete when logging out (since I use Entourage on my Mac to pull in the emails from multiple email addresses I use).
     
    Tron8888, Nov 12, 2013 IP