How often you purge Informix log files? I am sure most of you cleanup your log files on regular basis. However there are people, to whom purging log files comes as a reactionary in troubleshooting a file system full situation. Do you know there is way within Informix to programmatically manage common log files e.g., message.log, bar_act.log, bar_debug.log etc. Informix introduces this capability in version 11.70.xC3 to target embedded environment, where disk space is fixed and database instance must run years without intervention from administrators. Nevertheless administrators can take the advantage of this functionality to organize Informix log files outside the embedded environment also. The Auto Rotate Log feature provides a platform independent way to automatically manage Informix log files. This feature implemented via database scheduler that provides the flexibility to use it from dbaccress using SQL admin API, as well as from OAT.
Using this feature you can rotate, truncate, or delete log files. It can be run manually or automatically. However, to perform this operation automatically you need to enable it first. There are several new admin API commands added for this feature:
- file rotate
- file truncate
- file delete
Let’s take a look couple of examples for better understanding. Manually Rotate Log File
The rotate operation switches to a new log file and increments the ID numbers for the previous log files by one. When the maximum number of log files is reached, the oldest log file deleted. To rotate the "/usr/informix/online.log” and keep last 10 files use: EXECUTE FUNCTION task("file rotate", "/usr/informix/online.log", 10); Manually Truncate Log File
The truncate operation removes the contents but keep the log file. To truncate "/usr/informix/bar_act.log", specify: EXECUTE FUNCTION task("file truncate", "/usr/informix/bar_act.log"); Manually Delete Log File
The delete operation removes the file. To delete the entire "/usr/informix/bar_debug.log" file, specify: EXECUTE FUNCTION task("file delete", "/usr/informix/bar_debug.log");Automatic Rotate Log
There are three tasks added to sysadmin:ph_task task table to automatically rotate log files, for example: online_log_rotate, bar_act_log_rotate and bar_debug_log_rotate. The tk_enable column in sysadmin:ph_task table for appropriate task needs to be enabled to rotate log automatically. You only need to enable each task once.
You can manage log files from OAT v.2.73 and higher. The rotate, delete and truncate log operations are available under “Logs” section on the left pane.
This is a neat and useful feature that can make administrator’s life little easier.