> awk | sed

As a general rule, you never need more than a single of awk, sed, grep,
cut in the same pipeline.  Also, xargs (on Linux) would generate a silly
error-message (which cron will dutifully e-mail to you), if no matching
open files were found. The improved (and less prone to race-conditions)
expression for the same would be:

postrotate
         lsof | awk '
                  $9 ~ /^\/var\/log\/upstart\/.*\.log.+/ {
                           service = gensub("^.*/(.*).log.*", "\\1", $9);
                           system("service " service " restart")
                  }
         '
endscript

But, you only need lsof if you insist on sharedscripts (which is not in
there in the default file installed by the upstart package).

If you do NOT add the sharedscripts-verb, you can bypass the entire lsof
part, because the full path of the log being rotated will be passed to
the postrotate-script as the first argument:

postrotate
         service=${1##*/}
         service=${service%.log*}
         service $service restart
endscript

You can also insert special handling for some of the services easier
this way, for example:

         case $service in
         fpm*)
                 exit 0
                 ;;
         .....
         esac

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1350782

Title:
  Upstart does not reopen /var/log/upstart/* logfiles upon log rotation

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/1350782/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to