Difference between revisions of "Clean Out Temporary Files"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 12: Line 12:
 
That command will report
 
That command will report
 
Removed 0 images.
 
Removed 0 images.
since you have already removes all the temporary images. The important thing is that it silently cleans out the <depths> table. In fact, the way <code>remove_stale_images</code> works is that it totally clears out the <depths> table and then adds the necessary information for any images that remain.
+
since you have already removes all the temporary images (or on a very active server, it may remove a few that have just been created). The important thing is that it silently cleans out the <depths> table. In fact, the way <code>remove_stale_images</code> works is that it totally clears out the <depths> table and then adds the necessary information for any images that remain.
   
 
==Using the remove_stale_images script==
 
==Using the remove_stale_images script==

Revision as of 18:34, 1 February 2012

The WeBWorK system creates and saves a large number of temporary files, e.g. png images of equations, pdf downloads, etc. If e.g. a png image of an equation already exists, it is faster for WeBWorK to locate and use that image than to create a new one. However, eventually the number of temporary files will become very large (especially for large installations) and over time only a very small number of them will be used. Thus it is a good idea, especially for large installations, to clean out temporary files say every semester. WeBWorK will recreate any temporary file it needs that does not already exist, so there is no harm in removing temporary files.

Removing temporary files when a wwtmp directory is set up

Removing temporary files is most important for large installations and I assume all large installations will set up WeBWorK so that all temporary files are places in a separate directory or partition (see Store WeBWorK's temporary files in a separate directory or partition). In this case, simply so the following:

cd to the wwtmp directory (e.g. cd /var/www/wwtmp)

and as root remove everything in that directory

sudo sudo rm -rf *

We still have to clean out the <depths> table in the MySQL database that saves information on the depths of the png images of equations so that they get displayed nicely. Fortunately this is very easy to do. Simply run the command

remove_stale_images --delete --days 0

That command will report

Removed 0 images.

since you have already removes all the temporary images (or on a very active server, it may remove a few that have just been created). The important thing is that it silently cleans out the <depths> table. In fact, the way remove_stale_images works is that it totally clears out the <depths> table and then adds the necessary information for any images that remain.

Using the remove_stale_images script

If you have a small installation and do not have a wwtmp directory, you can still easily remove all or some of the temporary equations images by running the remove_stale_images command;

remove_stale_images --delete 

will moves all images older than 7 days

remove_stale_images --delete --days 0

will remove all images.

remove_stale_images --help

will list all options.

Removing Stale png images of equations

There is a script remove_stale_images that