3

How can I pass a command-line argument to the atd daemon which will persist across reboots and package upgrades? I wish to add the command line flag -l 7.5 to atd because I have an 8-CPU server and don't want to wait for the load level to go below the compiled-in value of 1.5 before running batch jobs.

(A similar question has been answered here, but that answer is not valid for Ubuntu 16.04 because the file /etc/init.d/atd.conf does not exist, and there is no line "exec atd" in my /etc/init.d/atd file.)

Unlike most of the scripts in /etc/init.d/, there is no corresponding atd file in /etc/defaults/ so I can't make any edits in there.

Here is the /etc/init.d/atd script:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          atd
# Required-Start:    $syslog $time $remote_fs
# Required-Stop:     $syslog $time $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Deferred execution scheduler
# Description:       Debian init script for the atd deferred executions
#                    scheduler
### END INIT INFO
#
# Author:       Ryan Murray <rmurray@debian.org>
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/atd
PIDFILE=/var/run/atd.pid

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
  start)
        log_daemon_msg "Starting deferred execution scheduler" "atd"
        start_daemon -p $PIDFILE $DAEMON
        log_end_msg $?
    ;;
  stop)
        log_daemon_msg "Stopping deferred execution scheduler" "atd"
        killproc -p $PIDFILE $DAEMON
        log_end_msg $?
    ;;
  force-reload|restart)
    $0 stop
    $0 start
    ;;
  status)
    status_of_proc -p $PIDFILE $DAEMON atd && exit 0 || exit $?
    ;;
  *)
    echo "Usage: /etc/init.d/atd {start|stop|restart|force-reload|status}"
    exit 1
    ;;
esac

exit 0

I have tried adding -l 7.5 to the end of the start_daemon line in the start) section but that didn't make any difference (I still have a job in my queue although my load level is below 7.5; and ps -ef | grep atd | grep -v grep yields daemon 23192 1 0 07:57 ? 00:00:00 /usr/sbin/atd -f)

5

What you're looking at there is an old-style SysV init file. Although systemd provides a mechanism (for backward compatibility) to start services via such files via a sysv init compatibility mode, Ubuntu 16.04 does not appear to do so in this case, so your changes to the init file are simply ignored - I'm not sure why the file is still present.

Instead, the atd service is started directly by systemd, using the unit file /lib/systemd/system/atd.service. However, rather than editing that file directly, you should use systemctl edit to create a custom configuration as described in @muru's excellent answer How do I override or configure systemd services?

Specifically,

sudo systemctl edit atd

then add for example

[Service]
ExecStart=
ExecStart=/usr/sbin/atd -l 7.5 -f

Save and quit, then restart the service unit

sudo systemctl restart atd.service

After that you can confirm your change has taken effect using

systemctl status atd.service

You should see something like

● atd.service - Deferred execution scheduler
   Loaded: loaded (/lib/systemd/system/atd.service; enabled; vendor preset: enab
  Drop-In: /etc/systemd/system/atd.service.d
           └─override.conf
   Active: active (running) since Sat 2017-06-10 09:38:30 EDT; 8min ago
     Docs: man:atd(8)
 Main PID: 17247 (atd)
   CGroup: /system.slice/atd.service
           └─17247 /usr/sbin/atd -l 7.5 -f

Jun 10 09:38:30 xenial-vm systemd[1]: Started Deferred execution scheduler.
  • Thanks. Interestingly, having made that change, I checked what happens running /etc/init.d/atd start (I now realise this is deprecated but I grew up with Solaris in the 1990s and old habits die hard) and it now gives the message 'Starting atd (via systemctl)...' which I'm almost certain it didn't do before. Indicative of a bug in the Ubuntu 16.04 release? (This is pretty close to vanilla) – nickcrabtree Jun 10 '17 at 21:21
  • In the case where there is a both ".service" file and an "init.d" file, the .service file "wins" and the init.d file is not loaded. Both may be present simply because the software is packaged for multiple operating systems or to support the brave souls that switch their Ubuntu 16.04 init systemd from systemd back to Upstart. – Mark Stosberg Jun 12 '17 at 19:59

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.