WeBWorK Main Forum

remove_stale_images

remove_stale_images

by Lars Jensen -
Number of replies: 4
Hi Everyone,

The remove_stale_images script does not seem to remove images in the html/tmp/gif directories under the courses. We have quite a few images there. Is there any reason these are not removed by the script?

Thanks,
Lars.
In reply to Lars Jensen

Re: remove_stale_images

by Jason Aubrey -
Hi Lars,

Good point. It looks like it was written with only png files in mind.

Jason
In reply to Jason Aubrey

Re: remove_stale_images

by Lars Jensen -
Hi Jason,

The images we have in html/tmp/gif are not gifs - they are in fact png's. I think the problem is that the script doesn't look to delete files in that directory.

Lars.
In reply to Lars Jensen

Re: remove_stale_images

by Michael Gage -
That may well be true -- originally I believe John Jones created it mainly to clear out the equations directory.

In turns of work around -- I believe that you can delete anything in the htdocs/tmp directory -- all _should_ be regenerated although it might slow down the server for a little while. If you want to play it safe just mv the
tmp file to an alternate location and see what happens.

I'll look further into why some of the directories aren't automatically created eventually -- but it might take a little while.
-- Mike
In reply to Michael Gage

Re: remove_stale_images

by John Jones -
Hi,

Mike is right that my main concern at the time was images for equations. The situation for equation images and other tmp images is a little different, but worth dealing with.

Webwork caches equation images on the grounds that an image made today might be accessed again in a week or a month, etc. They are not tied to a particular course or user. Some of them are for things like $x$ and $y$ which probably get accessed every day, so you pretty much never want to regenerate them. So, remove_stale_images will let you remove those images based on the last time they were accessed. Some more exotic equation image may in fact exist because of one seed for some problem, and after a month it is probably not going to be used again. So, you can save on disk space by cleaning out images which haven't been used in a while.

The contents of html/tmp are basically intended to be used once (e.g., which you generate hardcopy). There may be exceptions (it is possible that webwork does not regenerate an on-the-fly graphics image if one already exists; then again, it might just regenerate anyway), but these don't get used very often. Anyway, the expected time frame for which the image is useful will be much shorter. It would make sense to have a daily cron job which wipes out any files in html/tmp/* which have not been accessed within the last hour. So, the time limit for html/tmp should be controlled separately from the time limit for the equation cache. It might be easier to do this through a separate utility. I have one, but it would need a little improvement for general usage (it has the path to the courses directory as a variable, but with the value hard-wired, whereas it should figure this out itself). If people want it, I can upload it into webwork, and then let someone else sort out that last detail.

Ideally, I guess webwork should have a file which can be executed by cron on a daily basis. One would set parameters in global.conf for things like how long to keep equation images and html/tmp (based on access time), and the initial webwork installation process would install the one cron job.

John