I want to ionice a process on its startup.

In our hosting environment, we use old Paralells Confixx servers. (Yes I know, Confixx is outdated, but that is not the question).

We use courier for mails and sometimes it happens, that the /usr/bin/imap Maildir process eats up the whole I/O which also causes high CPU load. We allways manually ioniced (ionice –c 3 –p [PID]) the process and the I/O went down. What is the best way to automatically ionice every imap process? I’m not very experienced in the courier mail server.

3 Answers 3


Just run ionice on the IMAP main process. The setting is inherited by the child processes.

Maybe it also helps to run find /path -printf"" every minute or so on all the mail directories to keep the metadata in the page cache (unless that is too much data and you need the cache more for other stuff).

  • How do i get the PID of the main process? when i ps aux --forest | grep imap i can see: root 32071 0.0 0.0 6364 472 ? S May23 0:06 /usr/sbin/courierlogger -pid=/var/run/courier/imapd-ssl.pid -start -name=imapd-ssl /usr/sbin/couriertcpd -address=0 -maxprocs=140 -maxperip=60 -nodnslookup -noidentlookup 993 /usr/bin/couriertls -server -tcpd /usr/lib/courier/courier/imaplogin /usr/bin/imapd Maildir but ionice this process takes no effect May 24, 2018 at 11:13
  • @SimonSutter The main process is the one listening on the IMAP port: ss -nlt4 | grep -F -e :143 -e :993 May 25, 2018 at 18:23

As another solution you can put courier process to separate cgroup hierarchy and specify parameters (IO bandwidth in your case) for block IO controller.

Particular simple example which I've find can be got from this link.

Also, you can specify another controllers parameters such as cpuact, memory, net_prio. Much more you can find at Linux Kernel Documentation.

  • I can see the attempt in this article, but the writer gives a flag to a dd comman. I don't know how i can give the imap process such a flag whitout modifying the "ecosystem" of the confixx - courier-imap environment. May 24, 2018 at 11:36
  • I found out, that you can pass the pid in the pidfile of courier (/var/run/courier/imap.pid) to the cgroup for blkio (in my case /sys/fs/cgroup/blkio/imap/cgroup.procs) but my problem is, the kernel of Debian 7 is not supporting blkio.throttle.read_bps_device and the other options do not seem to be useful in this case. The effort to change something in the kernel is too high and too risky. May 24, 2018 at 15:04
  • Yes. Debian 7 kernel doesn't support this feature. Please, specify distro name in future questions. It's will save your time when you will be try proposed suggestions. May 24, 2018 at 15:16

ionice on the main process doesn't seem to work, so i modifyed the initscript of the "courier-imap" and "courier-imap-ssl" and that seems to work:

case "$1" in
    if [ "$START" = "yes" ]; then
            log_daemon_msg "Starting $PROGRAM" "$DAEMON"
            umask $IMAP_UMASK
            ulimit -v $IMAP_ULIMITD
            /usr/bin/env - /bin/sh -c " set -a; \
            bindir=${bindir}; \
            . ${sysconfdir}/imapd; \
            if [ "$SSLCONFIG" ]; then . ${sysconfdir}/imapd-ssl; fi; \

            ionice -c3 /usr/sbin/courierlogger -pid=$PIDFILE -start $LOGGEROPTS \

            $TCPD -address=$ADDRESS \
                    -maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
                    $TCPDOPTS \
                    $PORT ${libexecdir}/courier/imaplogin \
                            ${bindir}/imapd $MAILDIRPATH"
            log_end_msg 0

If someone has improvement suggestions, please tell me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.