Table of Contents

Rotating log files

Various processes associated with your account store log files in ~/logs (and ~/domains/…/logs) during normal operation . While useful, if left unchecked these log files can quickly grow to use up all available space. In order to avoid this, log files can be automatically compressed and deleted through a process known as log rotation.

Rotating Apache logs

By default, Apache is the only process which will store log files under your account's home directory. Specifically, the files ~/logs/access_log and ~/logs/error_log, as well as their counterparts for any subdomains used, are created by Apache.

Shared accelerators are configured to automatically rotate the access_log daily at approximately 0:00 GMT. Archived copies of this file are retained for 120 days. This cannot be disabled or modified.

The error_log file, however, is not rotated automatically. Since error logging is disabled by default, this is not normally a problem. However, if you have enabled error logging over a long period of time, you will need to manually create a rotation task for this file using the instructions in the next section.

Rotating other logs

If you have any other processes which create log files, such as Procmail or a Ruby on Rails application, you will want to create a custom log rotation task. This can be done by following the following steps:

  1. Download the following file and save it as ~/etc/logrotate.conf: logrotate.conf
    This file uses the same defaults used by the shared accelerators when rotating Apache's log files. However, you may modify these defaults or set file-specific settings as needed. More information about the symtax of this file is available at http://linux.die.net/man/8/logrotate.
  2. Under “Files to rotate”, replace username and logfile_name as appropriate. If you have more than one log file that needs to be rotated, duplicate the the two lines at the end of the above text as necessary (being sure to include both curly braces).
  3. Save this file as ~/etc/logrotate.conf.
  4. Test your configuration by executing logrotate -d ~/etc/logrotate.conf. The -d displays diagnostic information while preventing logrotate from modifying any files. Note that is normal behavior for the output to indicate that no files need to be rotated yet, as logrotate will not have built up any history yet.
  5. Create a new cron script to execute the log rotation daemon. The cron job should use the following settings:
    • Command: /usr/local/sbin/logrotate -s $HOME/var/log/logrotate.status $HOME/etc/logrotate.conf
    • When To Execute: This is up to you. It is usually not necessary to run logrotate more than once per day. Be considerate of other users.

See also