-1

I'm trying to set up a systemd time that runs every 4 hours. When the timer fires a script is run to update some data files. I followed systemd timer every 2 hours at 30 minutes past the hour? and systemd timer every 15 minutes.

File /etc/systemd/system/ftc-data.service:

[Unit]
Description=Fetch FTC Do Not Call data files

[Service]
Type=oneshot
ExecStart=/var/ftc/ftc-data/fetch-data.sh

File /etc/systemd/system/ftc-data.timer:

[Unit]
Description=Run ftc-data.service every 4 hours

[Timer]
OnCalendar=00/4:00

[Install]
WantedBy=timers.target

Here's where the problems arise:

systemctl enable /etc/systemd/system/ftc-data.timer
systemctl start  /etc/systemd/system/ftc-data.timer
systemctl enable /etc/systemd/system/ftc-data.service

The commands result in:

# systemctl enable /etc/systemd/system/ftc-data.timer

# systemctl start  /etc/systemd/system/ftc-data.timer
Failed to start etc-systemd-system-ftc\x2ddata.timer.mount: Unit etc-systemd-system-ftc\x2ddata.timer.mount not found.

# systemctl enable /etc/systemd/system/ftc-data.service
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.

It looks like the problems start when trying to enable ftc-data.timer. I'm trying to make sense of Failed to start etc-systemd-system-ftc\x2ddata.timer.mount: Unit etc-systemd-system-ftc\x2ddata.timer.mount not found. but I am not finding hits when searching for it. I found one post at Newbie Corner » Unit timer, but the fellow went back to using cron because timers are so f**k'd up with systemd.

Here is the systemd.mount docs, but damn if I can tell what's wrong with things after reading it. I have no idea what a filesystem mount has to do with things. All I want to do is run a script every 4 hours.

I'm really missing cron around now. cron is simple and just works. It has been replaced with something more complicated that does not work. Sigh...

What needs to be fixed (besides systemd)?


This is a Fedora 29 Server and SELinux is in enforcing mode. This may have something to do with things:

# ls -Zd /var/ftc/ftc-data/fetch-data.sh
unconfined_u:object_r:httpd_sys_content_t:s0 /var/ftc/ftc-data/fetch-data.sh

The web server has access to /var/ftc/ftc-data/ because it needs to serve documents from the directory Also see How to troubleshoot Nginx permission denied in subdirectory?

  • 1
    You removed the accepted mark from the answer. What part of this question do you believe remains unanswered? – Michael Hampton May 5 at 3:51
3

You're meant to provide the name of the unit, not the path to a file.

You should have done instead:

systemctl enable ftc-data.timer
systemctl start ftc-data.timer
systemctl enable ftc-data.service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy