I wrote a very simple script (
checkaudio.sh) that publishes a message from a file on a mqtt topic. I would like the script to run continuously (I would be happy even with every second). I first tried with cron, which is technically possible but "dirty" as a solution (multiple cron jobs with a 1 second delay each).
I have the tried with
systemd and its
timer function. I'm not very proficient with systemd, and this is what I came up with:
[Unit] Description=Announce every second [Install] WantedBy=default.target [Service] Type=oneshot ExecStart=/root/checkaudio.sh
[Timer] OnUnitActiveSec=1s AccuracySec=1ms Unitfirstname.lastname@example.org
I activated the two above through
Everything was running smoothly until I rebooted the system and I could not enable
/email@example.com anymore. I am getting the following error:
The unit files have no installation config (WantedBy, RequiredBy, Also, Alias settings in the [Install] section, and DefaultInstance for template units). This means they are not meant to be enabled using systemctl. Possible reasons for having this kind of units are: 1) A unit may be statically enabled by being symlinked from another unit's .wants/ or .requires/ directory. 2) A unit's purpose may be to act as a helper for some other unit which has a requirement dependency on it. 3) A unit may be started when needed via activation (socket, path, timer, D-Bus, udev, scripted systemctl call, ...). 4) In case of template units, the unit is meant to be enabled with some instance name specified.
What am I doing wrong? Is there a better way to achieve my initial objective of running the script continuously?