Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-46882

MongoDB keeps deleted log files open after rotation

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.5
    • Component/s: Logging
    • Labels:
    • Environment:
      RHEL 7.x Linux x64, MongoDB 3.6.5 Community, Sharded Cluster

      I made a script to rotate the logs every day, but my log files remain open after the rotation (see attachment).

      Even if I restart the mongod processes, this problem will appear in the next few days.

      Is there a problem with my script? Or the "kill -SIGUSR1 <pid>" command cannot be used when MongoDB is balancing? 

      Any suggestions or root cause guessing?

      Thanks~

      $ crontab -l
      ==========================
      05 00 * * * /opt/log_bk.sh

       

      $ cat /opt/log_bk.sh
      ==========================
      #!/bin/sh
      /bin/kill -SIGUSR1 `cat /opt/foo/conf/SB/SB11.pid 2> /dev/null` 2> /dev/null || true
      mv /opt/foo/logs/SB/SB11.log.* /opt/foo/logsbk/SB
      compress /opt/foo/logsbk/SB/SB11.log.*

      /bin/kill -SIGUSR1 `cat /opt/foo/conf/SB/SB31.pid 2> /dev/null` 2> /dev/null || true
      mv /opt/foo/logs/SB/SB31.log.* /opt/foo/logsbk/SB
      compress /opt/foo/logsbk/SB/SB31.log.*

      find /opt/foo/logsbk/SB/ -type f -name "*.Z" -mtime +7 -exec rm -rf {} \;

       

       

       

       

       

        1. lsof deleted 1.png
          lsof deleted 1.png
          659 kB
        2. lsof deleted 2.png
          lsof deleted 2.png
          1.07 MB

            Assignee:
            Unassigned Unassigned
            Reporter:
            seth.chuang@thinkpower-info.com 興旺 莊
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: