Script to delete files from spesific directory

Discussion in 'Installation/Configuration' started by DDD_DDD, Oct 25, 2009.

  1. DDD_DDD

    DDD_DDD New Member

    Hello. i need some help..

    i need a script to check the directory "/test/test2/". If in this directory there are files with number extensions (like test.1111, test.6500, test.5054 - only files with name test and extension number) i want to delete them. I want this script to run every 5 seconds. It's VERY important for me to have this script. can someone make it for me? I'm running debian.. thanks!
     
  2. Franz

    Franz Member

    find /path/tho/files -name test.* -exec rm {} \;
    or
    find /path/tho/files -name test.[1234567890]* -exec rm {} \;


    in cron you can run every 1 minute.
     
  3. martinfst

    martinfst ISPConfig Developer ISPConfig Developer

    You could use the following code and place it in crontab:
    Code:
    find /test/test2 -name 'test.*' -exec rm {}\;
    Make sure you use the crontab of a user with sufficient rights.
     
  4. martinfst

    martinfst ISPConfig Developer ISPConfig Developer

    You will have to put quotes around the '*', or else the shell will expand it before the find command.
     
  5. DDD_DDD

    DDD_DDD New Member

    thanks for the answers!

    this will delete the test.(+nubmers)? cause in the folder there's and the test.so.

    which is the cronjob to run it every 5 seconds??
     
  6. martinfst

    martinfst ISPConfig Developer ISPConfig Developer

    Code:
    man crontab
     

Share This Page