Cron Job to clean a directory and keep index.html

Discussion in 'Site & Server Administration' started by Ricardo Corai, Mar 26, 2015.

  1. #1
    Hi,

    I'm using CPanel and I need to clean a tmp directory but keep index.html for security reasons. What's the command should I use to clean everything except index.html?

    Thanks.
     
    Ricardo Corai, Mar 26, 2015 IP
  2. TheSHosting

    TheSHosting Member

    Messages:
    24
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    48
    #2
    What level of access you have; just cPanel level access? Anyway, a command like following will remove all files except index.html. So you can create a script with following content and set it as a cron and it should work.

    PS: make sure to replace <complete path to dir> with full path to the tmp directory.
     
    TheSHosting, Mar 27, 2015 IP