Without intervention, the LDM logfile , ldmd.log, will grow without bound. For this reason, it is desirable to have an automatic process manage the LDM logfile. A convenient mechanism for curtailing growth is provided by the ldmadmin newlog command in conjunction with the UNIX crontab utility.
The ldmadmin newlog command rotates through the last $numlogs logfiles of the LDM, where $numlogs is a user-customizable variable in the ldmadmin script. The command causes every logfile matching the patten ldmd.log.n, where n is a positive integer less than $numlogs, to be renamed ldmd.log.n+1, where n+1 denotes the next higher integer. This action will proceed from the larger n-s to the smaller so that no logfile is lost. Then, the file ldmd.log is renamed ldmd.log.1. Finally an empty ldmd.log file is created.
For example, if the ldmadmin newlog command was executed at 18:00 on the 20th and if the $numlogs variable was 2, then the following files:
would become-rw-r--r-- 1 ldm staff 972 Sep 19 18:00 /opt/ldm/logs/ldmd.log -rw-r--r-- 1 ldm staff 845 Sep 18 18:00 /opt/ldm/logs/ldmd.log.1 -rw-rw-r-- 1 ldm staff 826 Sep 17 18:00 /opt/ldm/logs/ldmd.log.2 -rw-r--r-- 1 ldm staff 981 Sep 16 18:00 /opt/ldm/logs/ldmd.log.3
Note that the ldmd.log.3 file was untouched.-rw-r--r-- 1 ldm staff 0 Sep 20 18:00 /opt/ldm/logs/ldmd.log -rw-r--r-- 1 ldm staff 972 Sep 19 18:00 /opt/ldm/logs/ldmd.log.1 -rw-r--r-- 1 ldm staff 845 Sep 18 18:00 /opt/ldm/logs/ldmd.log.2 -rw-r--r-- 1 ldm staff 981 Sep 16 18:00 /opt/ldm/logs/ldmd.log.3
An excellent way to ensure that this rotation occurs on an automatic and regular basis is to execute the command out of the LDM user's crontab file. For example, the following entry will cause the command to be executed at 1800 hours local-time every day:
0 18 * * * bin/ldmadmin newlog
Because the timestamps in an LDM logfile are usually in UTC, a common convention is to rotate the logfiles at 0000 hours UTC. This is why the above example used 1800 hours MDT. (If we remember, we change the execution-time to 1700 MST when appropriate.) An alternative convention is to rotate the logfile at local midnight, e.g.,
Both conventions are equally valid. You'll just have to remember which one you use.0 0 * * * bin/ldmadmin newlog
We also like to keep a week's worth of LDM logfile entries around -- so we change the $numlogs variable to 7.
This rotation (and purging) of the LDM logfiles will ensure that the space occupied by the logfiles will not grow indefinitely.