[SOLVED]How to disable root mail

Discussion in 'ISPConfig 3 Priority Support' started by Tomislav Aurednik, Jun 5, 2017.

  1. Tomislav Aurednik

    Tomislav Aurednik Member HowtoForge Supporter

    How can I disable the root mail that is sent when you do something with root permissions (i think)? The problem is that it fills my mail queue on the inactive node server.
    The only thing I found was to change postmaster: /dev/null in /etc/aliases. But it does not work, I still have root mail in my mail queue.
     
  2. chico11mbit

    chico11mbit Member HowtoForge Supporter

    Just rm the /var/mail/root with a cron in intervals.
     
  3. Tomislav Aurednik

    Tomislav Aurednik Member HowtoForge Supporter

    This won't stop sending mail! I need to stop the sending of root mail so my mail queue doesn't get flooded when the node is in secondary mode (apache,postfix, dovecote,mysql,... services not running)!
    I could write a script that clears the mail queue when the node is secondary and run it with a cronjob. But I would rather just stop those root mail from being sent.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    In my opinion, mails to root are a core part of any Linux system, so you can not stop that easily as you woul have to alter / reconfigure all apps that potentially send emails to root. I would just empty the root mailbox from time to time like @chico11mbit mentioned it or redirect the mails from root to another mailbox with an alias or maybe you can use the alias to pipe all incoming root emails to /dev/null.
     
  5. Tomislav Aurednik

    Tomislav Aurednik Member HowtoForge Supporter

    So there is no simple way... I feard as much.
    Deleting the file won't solve my problem. The mails aren't delivered but are stuck in queue, because postfix, dovecot are not running while the node is slave.
    Problem is that the root mails are not delieverd but are in tme mail queue. Every few hours there are 100+ email in queue if I check with mailq.
    A few days and there are 10000+, because the services are not started. When the node becomes master it first need to deal with the mail queue, so the mail server does not work. I need to first clear it with:
    mailq | tail -n +2 | awk 'BEGIN { RS = "" }{ if ( $7 == "root" ) print $1 }' | tr -d '*!' | postsuper -d -
    Looks like I'll have to write a script that will run the above command on the slave node.
     
  6. Tomislav Aurednik

    Tomislav Aurednik Member HowtoForge Supporter

    ok... I created a script but it won't work from crontab?! If I start it manually it works ./script_name.sh.
    crontab entry
    * * * * * bash /usr/local/script/script_name.sh
    tryed also
    * * * * * /usr/local/script/script_name.sh

    script
    #!/bin/bash
    if [ ! -d /var/lib/mysql/dbispconfig ]; then
    mailq | tail -n +2 | awk 'BEGIN { RS = "" }{ if ( $7 == "root" ) print $1 }' | tr -d '*!' | postsuper -d -
    fi

    the script permissions are 500 and the owner is root:root
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Did you check the syslog to see if your script is really executed by cron?
     
  8. Tomislav Aurednik

    Tomislav Aurednik Member HowtoForge Supporter

    Yeah I checked it was executing. I needed to create a log for the script to figure out the problem. Needed to use the full path for /usr/sbin/postsuper command.
    Now I set it that it clears the mail queue on the slave node every 15min.
     
    chico11mbit and till like this.

Share This Page