CRON job to delete old files

Discussion in 'Programming/Scripts' started by tera7, Nov 5, 2007.

  1. tera7

    tera7 New Member

    Hello i want ot delete files older than 1 day i tried all this but nothing is working.

    find /var/www/html/search/ -mtime +1 -exec rm {} \;
    find /var/www/html/search -mtime +1 -type f -exec ls -la {} \;
    /usr/bin/find /var/www/html/search \( -type f -a -mtime +1 \) -exec rm -f {} \; 
    find . -name '*/var/www/html/search*' -atime +1 -delete
    find /var/www/html/search -mtime +1
    find /var/www/html/search/ -type f -mtime +1|xargs ls -l

    the last one just gives me an output of the root directory.
  2. sjau

    sjau Local Meanie Moderator

    Try this script:

    for file in "$( find /var/www/html/search/ -type f -mtime +1 )"
      rm -f $file
  3. chipsafts

    chipsafts New Member

    using xargs

    this is what we have setup
    find /home/log/Pr* -ctime +155 | xargs rm
  4. tera7

    tera7 New Member

    Yes this is how i did it too the main problem i had was with filenames(special char. etc.)

Share This Page