Using a cron job to empty/delete a folder

Discussion in 'Site & Server Administration' started by eduardomaio, Oct 9, 2005.

  1. #1
    Anyone know what is the command line to use with contrab to empty or delete a folder?

    I already tried 0 0 * * * rm -f home/user/public_html/folder/ but got no sucess... :(

    I think rmdir only removes a folder if it is empty...

    Anyone can help me with this?
     
    eduardomaio, Oct 9, 2005 IP
  2. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #2
    if you want to delete the folder including its contents:

    rm -rf /home/user/public_html/folder

    (no trailing slash; slash at the start of your path)
    if you want to remove everything in this folder, but leave the folder itself:

    rm -f /home/user/public_html/folder/*
     
    frankm, Oct 9, 2005 IP
    eduardomaio likes this.
  3. eduardomaio

    eduardomaio Peon

    Messages:
    450
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks a lot! It worked
     
    eduardomaio, Oct 9, 2005 IP