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
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.
-Sanjit Chakraborty