Check if unbound-anchor.timer enabled using relevance

I am seeking a method to verify if the unbound-anchor.timer is enabled by utilizing relevance that accesses systemctl options, such as is-enabled.

Example:

#systemctl is-enabled unbound-anchor.timer
enabled

#systemctl is-enabled unbound-anchor.timer
disabled

Thanks.

Checked with Google Gemini the following -

The systemctl is-enabled unbound-anchor.timer command determines if the unbound-anchor.timer unit is configured to start automatically at system boot. Here’s a breakdown of how systemctl achieves this:

  1. Systemd Unit Files:
  • Systemd relies on unit files, which are configuration files that describe services, timers, sockets, and other system components.
  • These unit files are typically located in directories like:
    • /usr/lib/systemd/system/ (for packages installed by the system)
    • /etc/systemd/system/ (for user-created or customized units)
    • /run/systemd/system/ (units generated at runtime)
  • The unbound-anchor.timer file itself will be in one of those directories.
  1. Symbolic Links:
  • Systemd uses symbolic links to manage which units are enabled at boot.
  • Enabled units have symbolic links in the *.wants or *.requires directories within the target directories. Target directories represent runlevels or targets (e.g., multi-user.target, graphical.target).
  • For example, if unbound-anchor.timer is enabled for the multi-user.target, there will be a symbolic link pointing to the actual unbound-anchor.timer unit file in /etc/systemd/system/multi-user.target.wants/.
  1. systemctl is-enabled Logic:
  • When you run systemctl is-enabled unbound-anchor.timer, systemctl checks for the existence of these symbolic links.
  • Specifically, it looks within the relevant target directories for a symbolic link that points to unbound-anchor.timer.
  • If a symbolic link is found, systemctl reports “enabled.”
  • If no symbolic link is found, systemctl reports “disabled.”
    In simpler terms:
  • “Enabled” means there’s a shortcut (symbolic link) telling systemd to automatically start the timer during the boot process.
  • “Disabled” means no such shortcut exists, and the timer won’t start automatically.
    Example:
    If unbound-anchor.timer is enabled, you might see a symbolic link like this:
    ls -l /etc/systemd/system/timers.target.wants/unbound-anchor.timer
    lrwxrwxrwx 1 root root … /etc/systemd/system/timers.target.wants/unbound-anchor.timer → /usr/lib/systemd/system/unbound-anchor.timer

This link indicates that the unbound-anchor.timer unit is enabled for the timers.target.
Key points:

  • systemctl is-enabled doesn’t check if the timer is currently running, only if it’s configured to start automatically.
  • The target directory that contains the symbolic link determines when the unit will be started during the boot process.
  • The timers.target indicates that the timer will be started when the system reaches the timers target.

Can you please verify about the existence of those files?

I’m not near a computer right now

I’m not sure that i’m fully understanding your question but if your trying to run systemctl commands with relevance, that isn’t how BigFix Relevance works. Relevance is a read only query language, so you can query information from the OS but you can’t initiate actions, that is what Actionscript is for. You could execute a command in Actionscript then use relevance to read the output from the command to confirm that it’s applied correctly but you can’t actually use relevance to execute the command.
If the output file unbound-anchor.timer file shows, disabled or enabled in the file then something like this might work for you.
Depending on whether that is the only folder path, I believe this will do what you are looking for.

exists lines whose (it contains “enabled”) of file "/etc/systemd/system/multi-user.target.wants/unbound-anchor.timer

or something like this to check for multiple folders

exists lines whose (it contains “enabled”) of files “unbound-anchor.timer” of folders (“/etc/systemd/system/multi-user.target.wants”; “/lib/systemd/system/multi-user.target.wants”)

Thanks for your suggestions.

I ended up going after the symbolic link and it’s working!

exists symlink "/etc/systemd/system/timers.target.wants/unbound-anchor.timer"
3 Likes