Incorrect test used for anacron being active

Bug #1759846 reported by Gordon Lack
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cron (Ubuntu)
New
Undecided
Unassigned

Bug Description

/etc/crontab uses

   test -x /usr/sbin/anacron

for whether anacron is handling the daily/weekly/monthly cron jobs on a system.
This means that if anacron is installed it is assumed to be running.
However, this is a service, and can be disabled and since the package is installed by default it's simpler to just disable it on systems where you don't want it running rather then remove it.

Changing the test to be:

    systemctl --no-pager is-enabled anacron 2>/dev/null

(and changing the || to be &&, since the login is now reversed) caters for either case by checking what you really wish to know - is it active, not just installed.

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: cron 3.0pl1-128ubuntu5
ProcVersionSignature: Ubuntu 4.13.0-37.42-generic 4.13.13
Uname: Linux 4.13.0-37-generic x86_64
ApportVersion: 2.20.7-0ubuntu3.7
Architecture: amd64
CurrentDesktop: KDE
Date: Thu Mar 29 13:33:47 2018
InstallationDate: Installed on 2017-11-01 (147 days ago)
InstallationMedia: Kubuntu 17.10 "Artful Aardvark" - Release amd64 (20171017.1)
SourcePackage: cron
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Gordon Lack (gordon-lack) wrote :
Revision history for this message
Gordon Lack (gordon-lack) wrote :

Actually
    systemctl -q is-enabled anacron 2>/dev/null
works to, and is shorter (and more intuitive).

Revision history for this message
Gordon Lack (gordon-lack) wrote :

This is *still* an issue nearly a year on.

A better test line is actually this, which checks for anacron being present before checking whether it is enabled:

( test -x /usr/sbin/anacron && systemctl -q is-enabled anacron )

The () are needed.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.