The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cause of "Cannot open main log file "/var/log/exim/mainlog": Permission denied" - exicyclog?

Discussion in 'E-mail Discussions' started by grc, Sep 30, 2013.

  1. grc

    grc Registered

    Joined:
    Sep 30, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello,

    I run exicyclog every hour as a root cronjob.

    Occasionally, exim somehow crashes at around the same time. The only clue about what may have happened is the paniclog:

    paniclog shows:
    2013-09-27 14:00:03 Cannot open main log file "/var/log/exim/mainlog": Permission denied: euid=93 egid=93

    Looking at exicyclog, at one point it does the following:
    [...]
    if [ -f $mainlog ]; then
    $mv $mainlog $mainlog.$first
    $chown $user:$group $mainlog.$first
    $touch $mainlog
    $chown $user:$group $mainlog
    $chmod 640 $mainlog
    fi
    [...]


    I wonder if exim (Exim version 4.72) has a problem with the mainlog being touched by root temporarily if it tries to write to it before the "chown".

    Is that possible? What can be done about it?

    Kind Regards,
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    It looks like the error message is generated during the time frame when the Exim mainlog does not exist. You may want to modify your exicyclog script to run less often, or to rotate the log rather than moving it with that cron job.

    Thank you.
     
  3. grc

    grc Registered

    Joined:
    Sep 30, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thank you for your suggestions. The exicyclog script comes with Exim and is recommended to be run as a cronjob. So I thought someone has had the same problem and I would not have to re-invent the wheel :) or that I am on the wrong track. Btw: This does not happen very often, about every 5000th time exicyclog runs (estimated over the number of exim servers). Less often than hourly is unfortunately not an option.

    At this point I think the following modification of exicyclog may be worth a try:

    if [ -f $mainlog ]; then

    # modification 20131010
    # make sure the new mainlog has been created,
    # has the right permission
    $touch $mainlog.new
    $chown $user:$group $mainlog.new
    $chmod 640 $mainlog.new

    $mv $mainlog $mainlog.$first
    # ...and then move it into place ;should take less time
    $mv $mainlog.tmp $mainlog

    $chown $user:$group $mainlog.$first

    fi
     
Loading...

Share This Page