DP9: trimming logs

There are a lot of log files that are growing.  Is there a way to trim them automagically after reviewing the contents?

/omniback/var/opt/omni/log

(root@sapbck)# ls -lrt

-rw-rw-rw- 1 root root 3495894 Nov 16 22:48 debug_d2d.log

-rw-r----- 1 root sys 26505 Nov 17 07:30 poweronvms_cleanup.log

-rw-rw-rw- 1 root sys 538949 Nov 17 08:00 crs_profile.log

-rw-rw-rw- 1 root root 138717066 Nov 17 08:31 inet.log

-rw-r--r-- 1 hpdp users 24877882 Nov 17 08:32 hpdp-idb-cp.log

-rw-rw-rw- 1 root sys 68840058 Nov 17 08:33 debug.log

 

Tags:

Parents
  • Hi

    You can create yourself a cron job to backup them to a different place/filename and then empty/trim them ( > logfile.log )

    Or you can check logrotate utility which allows scheduling, trimming by size, compressing, renaming adding dates and much more.

    You can check some examples here:

    http://www.thegeekstuff.com/2010/07/logrotate-examples/

    Whatever you do, please never delete any of this logfiles while the DP processes are writing to them.

    On Unix/Linux systems this will cause the File to dissapear from "ls" command output, but the file descriptor will not be freed from the file system, resulting in disk space not being freed until the process writing to the log is stopped or receives the SIGHUP signal.

    Run this instead:

    # > logfile.log

     

    Regards

    Juanjo

  • Whatever you do, please never delete any of this logfiles while the DP processes are writing to them.
     
    I guess fuser them?  What about a log file that is being held open by DP?
     

    (root@sapbck)# fuser hpdp-idb-cp.log

    hpdp-idb-cp.log: 7146o

    (root@sapbck)# ps -ef | grep 7146 | grep -v grep

    hpdp 7146 1 0 Nov 15 ? 1:21 /opt/omni/idb/bin/pgbouncer -d /etc/opt/omni/server/idb//hpdp-idb-cp.cfg

Reply
  • Whatever you do, please never delete any of this logfiles while the DP processes are writing to them.
     
    I guess fuser them?  What about a log file that is being held open by DP?
     

    (root@sapbck)# fuser hpdp-idb-cp.log

    hpdp-idb-cp.log: 7146o

    (root@sapbck)# ps -ef | grep 7146 | grep -v grep

    hpdp 7146 1 0 Nov 15 ? 1:21 /opt/omni/idb/bin/pgbouncer -d /etc/opt/omni/server/idb//hpdp-idb-cp.cfg

Children
  • Yes, fuser will tell you the PID of the process writing to this file.

    Most processes behave "correctly" when you trim their log files using the ">" redirection command.

    Sometimes they don't (not often) and you will notice this because the log will stay zero size  after being trimmed as if the process is not writing to it anymore.

    In these cases, the processes can be forced to reopen their log files by sending them the SIGHUP signal:

    # kill -1   (one)

    So I would do this:

    1. Trim the log file by running -> # > hpdp-idb-cp.log
    2. Check that the file keeps growing and new log lines are being created
    3. If not force the process to reload -> # kill -1  7146

    There is no 100% guarantee that a process will respond to a SIGHUP signal anyway:

    https://en.wikipedia.org/wiki/SIGHUP

    SIGHUP can be handled. That is, programmers can define the action they want to occur upon receiving a SIGHUP, such as calling a function, ignoring it, or restoring the default action.

    But most of them do.

    In my experience trimming logfiles using the ">" command usually works and I don't remember having to send the SIGHUP signal to a DP process.