Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-5784

Usage of kill in logrotate script is non-portable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • other
    • None

      The logrotate script uses

      kill -SIGALRM `cat /var/run/hudson.pid`

      which works fine for the bash builtin, but fails for /bin/kill, which only accepts

      usage: kill [ -s signal | -p ] [ -a ] pid ...
             kill -l [ signal ]

      on CentOS 5.

      Using kill -s SIGALRM would make both variants happy and increase portability.

          [JENKINS-5784] Usage of kill in logrotate script is non-portable

          Robert Munteanu created issue -

          pdurbin added a comment -

          We are also seeing this problem on RHEL5.5, using the RPM from http://jenkins-ci.org/redhat/ (hudson-1.381-1.1 as this writing):

          /etc/cron.daily/logrotate:
          kill -SIGALRM `cat /var/run/hudson.pid`
          : line 1: kill: SIGALRM: invalid signal specification
          error: error running postrotate script for /var/log/hudson/hudson.log /var/log/hudson/access_log

          The recommendation above (using "kill -s SIGALRM") should fix the problem, but you could also consider calling /bin/kill explicitly and using -ALRM, as in the attached patch. Using "kill [-signal_name] pid" as noted in http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html seems to be the most popular approach on RHEL, at least. Compare /etc/logrotate.d/syslog, for example.

          pdurbin added a comment - We are also seeing this problem on RHEL5.5, using the RPM from http://jenkins-ci.org/redhat/ (hudson-1.381-1.1 as this writing): /etc/cron.daily/logrotate: kill -SIGALRM `cat /var/run/hudson.pid` : line 1: kill: SIGALRM: invalid signal specification error: error running postrotate script for /var/log/hudson/hudson.log /var/log/hudson/access_log The recommendation above (using "kill -s SIGALRM") should fix the problem, but you could also consider calling /bin/kill explicitly and using -ALRM, as in the attached patch. Using "kill [-signal_name] pid" as noted in http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html seems to be the most popular approach on RHEL, at least. Compare /etc/logrotate.d/syslog, for example.
          pdurbin made changes -
          Attachment New: hudson.logrotate.patch2010-10-20pdurbin [ 19874 ]

          sannies added a comment - - edited

          The patch works fine on our CentOS 5.5 hudson installation. Please apply! Changed priority to major since our guys maintaining the don't like manual steps after updating to a new version

          sannies added a comment - - edited The patch works fine on our CentOS 5.5 hudson installation. Please apply! Changed priority to major since our guys maintaining the don't like manual steps after updating to a new version
          sannies made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          changelog.html
          opensuse/SOURCES/jenkins.logrotate
          rpm/SOURCES/jenkins.logrotate
          http://jenkins-ci.org/commit/core/9c01038ab5cbd1a92e0a172a1834028b7862099f
          Log:
          [FIXED JENKINS-5784] logrotate script for RPM/openSUSE bug fix

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html opensuse/SOURCES/jenkins.logrotate rpm/SOURCES/jenkins.logrotate http://jenkins-ci.org/commit/core/9c01038ab5cbd1a92e0a172a1834028b7862099f Log: [FIXED JENKINS-5784] logrotate script for RPM/openSUSE bug fix
          SCM/JIRA link daemon made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          Olav Reinert added a comment -

          The applied patch is incorrect, the signal name is wrong.

          Olav Reinert added a comment - The applied patch is incorrect, the signal name is wrong.
          Olav Reinert made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]

          Olav Reinert added a comment -

          New patch to fix logrotate script for openSUSE. It works also when Jenkins is not running. Also, it checks that the ALRM signal really is sent to Jenkins and not some other process.

          Olav Reinert added a comment - New patch to fix logrotate script for openSUSE. It works also when Jenkins is not running. Also, it checks that the ALRM signal really is sent to Jenkins and not some other process.
          Olav Reinert made changes -
          Attachment New: jenkins-logrotate.patch [ 20237 ]

            Unassigned Unassigned
            rombert Robert Munteanu
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: