0

I'm sorry to post such a question but honestly, I've spent hours reading posts and still it doesn't work... Also if this should be posted else where but this felt like the right place.

I have a directory /home/username/exampledomain.com/html/cache/normal/exampledomain.com ...

Inside are files created by a caching system called Boost used by Drupal. The files I'm interested in have this syntax: page-name_foo.html and page-name_foo.html.gz. There is also one of each for just page-name_.html and page-name_.html.tz ... Just incase i'm not using foo correctly above, I mean foo could be anything...

So I've tried a few different things now and no success... The one that feels the closet is this:

find /home/username/exampledomain.com/html/cache/normal/exampledomain.com/  -maxdepth 1 -name 'page-name_*.html*' -type f  -exec rm {} \; > /dev/null

If I run this on the command line, it works perfectly... I have a control panel that lets me just point and click for setting the timings, that usually precede the command to run...

My interpretation of cron was that you could just use it to periodically run commands. I'm clearly mis-understanding things or it would just do it... :)

As always, all help or pointers are very much appreciated...

migrated from stackoverflow.com Feb 3 '14 at 23:25

This question came from our site for professional and enthusiast programmers.

0

I ended up doing this with a small php file and called it using crons "wget" command... Here's the php script:

<?php 

 $dir = '/home/username/exampledomain.com/html/cache/normal/exampledomain.com/';

  // check directory exists

  if (is_dir($dir)) {


  foreach(glob($dir.'page-name_*.*') as $SearchCacheFile ){

        unlink($SearchCacheFile);

        }

    }



    ?>

Here is the cron command:

wget -O - -q -t 1 http://exampledomain.com/sites/all/modules/custom_modules/small-php-script.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy