The atd daemon executes commands scheduled for one-off future execution via the at command. When atd.service fails to start on Ubuntu servers, batch job scheduling halts, and attempts to queue jobs produce errors such as Cannot open lockfile /var/spool/cron/atjobs/.SEQ or systemd startup exit failures.
Inspect Service Failure Details in Journalctl
Identify the precise root cause by examining the systemd diagnostic logs:
- Query the current status of the daemon:
sudo systemctl status atd.service - Check the detailed system log output:
sudo journalctl -u atd.service -e --no-pager - Common failure causes include missing spool directories, incorrect ownership on
/var/spool/cron/atjobs, or stale PID lockfiles.
Restore Correct Ownership and Permissions on At Spool Directories
The atd daemon enforces strict POSIX ownership constraints on its queue directory to prevent local privilege escalation:
- Verify the existence and permissions of the spool paths:
ls -ld /var/spool/cron/atjobs /var/spool/cron/atspool - If the directories are missing, recreate them:
sudo mkdir -p /var/spool/cron/atjobs /var/spool/cron/atspool - Set the required ownership to
daemon:daemon:sudo chown -R daemon:daemon /var/spool/cron/atjobs /var/spool/cron/atspool - Apply the strict octal permissions (1770 for atjobs):
sudo chmod 1770 /var/spool/cron/atjobs sudo chmod 700 /var/spool/cron/atspool
Remove Stale Lockfiles and Restart the Daemon
Abrupt system shutdowns or kernel panics can leave orphaned lockfiles in the spool directory:
- Remove any stale sequence or lock files:
sudo rm -f /var/spool/cron/atjobs/.SEQ /run/atd.pid - Reload the systemd configuration manager:
sudo systemctl daemon-reload - Start and enable the
atdservice:sudo systemctl restart atd.service sudo systemctl enable atd.service - Test scheduling functionality by queuing a test command:
echo "logger 'atd test successful'" | at now + 1 minute atq