Timing.log Rotation

From WeBWorK_wiki
Revision as of 18:00, 5 May 2020 by Apizer (talk | contribs) (Created page with "Here we will set up log rotation for WeBWorK's timing log which can grow huge especially if you have a large number of users. The <code>timing.log</code> gives timing informa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here we will set up log rotation for WeBWorK's timing log which can grow huge especially if you have a large number of users. The timing.log gives timing information on every action in WeBWorK (see WeBWorK_performance) and can be used to assess the performance of your server.

Create a WeBWorK configuration file for Logrotate

Logrotate’s configuration files are located in /etc/logrotate.d. Now we create one for WeBWorK.

$ sudo gedit /etc/logrotate.d/webwork

Now copy and paste the following code into gedit

/opt/webwork/webwork2/logs/timing.log {
su www-data wwdata
weekly
missingok
rotate 15
compress
delaycompress
notifempty
}

and then save the file and quit. The backup will be done weekly and we are keeping 15 weeks (approximately one semester) worth of logs. The most recent backup will not be compressed but all older ones will be. We are not explicitly creating a new timing.log file because WeBWorK will automatically create one if it's missing. If you want to check that it works you can run logrotate with the configuration file (make sure you have done something with WeBWorK so that the timing.log is not empty):

sudo logrotate -f /etc/logrotate.d/webwork
[sudo] password for wwadmin: <wwadmin password>

Then if you look in /opt/webwork/webwork2/logs, you should see

timing.log.1

You will not see a timing.log file unless someone has been doing something with WeBWorK. If there is no timing.log file do something yourself (e.g. login to a course) and then you should see

timing.log
timing.log.1

Now run logrotate again

sudo logrotate -f /etc/logrotate.d/webwork
[sudo] password for wwadmin: <wwadmin password>

and do something in WeBWorK and you should see

timing.log
timing.log.1
timing.log.2.gz

Here is what is going on. timing.log.1 was renamed to timing.log.2 and compressed giving timing.log.2.gz. timing.log was renamed to timing.log.1. And the something you (or someone else) did in WeBWorK created a new timing.log file. A similar procedure will happen weekly until there are a total of 15 backups after which the oldest one will be deleted.


-- Main.ArnoldPizer - 6 May 2020