WeBWorK Main Forum

how to safely remove growing number of png images?

how to safely remove growing number of png images?

by Hans Johnston -
Number of replies: 2
Hi All,

I gather that webwork creates png images of math symbols
in problems/hw sets and stores them in tmp directories, both in

webwork/webwork2/htdocs/tmp/equations

as well as subdirectories of individual courses. I noticed this
since I tar the entire contents of /opt/webwork each week as
a backup.

Is there a quick and dirty way to remove all of these, e.g. a
script? Or is it safe to just remove everything in

webwork/webwork2/htdocs/tmp

Thanks, Hans
In reply to Hans Johnston

Re: how to safely remove growing number of png images?

by Gavin LaRose -
Hi Hans,

We have the following in the crontab on our servers:

/usr/bin/find /var/www/webwork/webwork2/htdocs/tmp/equations -mtime +5 -a -type f -exec rm {} \; 2>/dev/null

which just wipes out every file in the equations directory that's 5 (or more) days old.

Gavin
In reply to Hans Johnston

Re: how to safely remove growing number of png images?

by Michael Gage -
The script


../webwork2/bin/remove_stale_images



can be used to accomplish this task. There are instructions at the top of the script. Another trick which will save storage space on backup is to place the tmp directory outside of the main webwork heierarchy. For example one can change the entry in the webwork2/conf/global.conf file:


# Location of web-accessible temporary files, such as equation images.
#$webworkDirs{htdocs_temp} = "$webworkDirs{htdocs}/tmp";
#$webworkURLs{htdocs_temp} = "$webworkURLs{htdocs}/tmp";
$webworkDirs{htdocs_temp} = "/ww/htdocs/tmp";
$webworkURLs{htdocs_temp} = "/tmp";


which places the tmp directory immediately under the main webserver directory where it is not backed up. As far as I know everything in the tmp directory can be recreated so it does not need to be backed up, the only penalty for deleting its contents is a slight performance hit while the cached equations and .gif files are being recreated.