Failed to start systemd timer and service

im getting the error: Failed to start git-auto.timer: Unit git-auto.timer not found.

I create 2 files in /etc/systemd/system:
git-auto.service
git-auto.timer

git-auto.timer:

[Unit]
Description="Run git-auto.sh"

[Timer]
OnCalendar=*-*-* 09:00:00
OnCalendar=*-*-* 18:00:00
Persistent=true

[Install]
WantedBy=multi-user.target

git-auto.service:

[Unit]
Description="Rodar git-auto-timer"

[Service]
ExecStart= my correct script location 

if i run : systemd-analyze verify /etc/systemd/system/git-auto.*
i dont get nothing, so looks right

I cant find the problem , any tips folks ?

Edit: im on silverblue

What package provides those files.?
Are they home-brewed or something else.?
They do not appear to be from a fedora repo.

They are not. I’m trying to create a timer to run a script that I did
The script name is git-auto.sh

Please share systemctl cat git-auto.timer and systemctl status git-auto.timer

Also what does systemctl list-timersreport?

Did you create these units as system or as user units? The latter would make most sense.

system users goes int /etc/systemd/system and user units goes into /etc/systemd/user.

For user units use systemctl --user ....

As you can see in the first post they are system units.
They may be better as user timers.

Did you use a text editor or “systemctl edit” to create the files?
In case of text editor, have you entered “systemctl daemon-reload” to make systemd aware of the new files?

2 Likes

For the timer the install section should be timers.target.

Have a look at Systemctl --user enable unit.timer does not start after reboot - #2 by grumpey

1 Like

I have never needed to use that target for system timers to work.

i change here but the error persist

yes i used text editor to edit, but late use nano

like: sudo systemctl --user start git-auto.timer ?
and just for me understand , its a recommendation like best practices , or it can solve the problem ?

got these 2 :

systemctl cat:
No files found for git-auto.timer.
systemctl status:
Unit git-auto.timer could not be found.

It is not a recommendation. The --user is for enabling or otherwise managing user services for a single user. For all users use --global instead.

As your units are system units, use neither or perhaps --system (which is assumed by default).

By the way: systemctl status git-auto.timer and systemctl status git-auto.service would be the first thing I would try.

Also for those who don’t know. After editing a unit file, run systemctl daemon-reload. The changes won’t take effect until you do.

Here is examnple out from my system with timers I have defined.

Please show exactly the commands you run and what the output is using the preformatted text feature. Its the </> button when you edit your response.

$ systemctl list-timers
NEXT                          LEFT LAST                              PASSED UNIT                         ACTIVATES
Mon 2023-12-18 11:59:01 GMT     2s Mon 2023-12-18 11:58:31 GMT      27s ago temperature.timer            temperature.service
Mon 2023-12-18 11:59:02 GMT     3s Mon 2023-12-18 11:58:31 GMT      27s ago givenergy.timer              givenergy.service
Mon 2023-12-18 12:09:47 GMT  10min Mon 2023-12-18 10:54:17 GMT  1h 4min ago dnf-makecache.timer          dnf-makecache.service
...

12 timers listed.
Pass --all to see loaded but inactive timers, too.

$ systemctl status temperature.timer
● temperature.timer
     Loaded: loaded (/etc/systemd/system/temperature.timer; enabled; preset: disabled)
     Active: active (waiting) since Sun 2023-12-17 08:54:56 GMT; 1 day 3h ago
    Trigger: Mon 2023-12-18 11:59:35 GMT; 23s left
   Triggers: ● temperature.service

Dec 17 08:54:56 fender.chelsea.private systemd[1]: Started temperature.timer.

$ systemctl cat temperature.timer
# /etc/systemd/system/temperature.timer
[Unit]
Description=temperature.timer

[Timer]
OnBootSec=60 seconds
OnUnitInactiveSec=30 seconds

[Install]
WantedBy=multi-user.target

$ ls -l /etc/systemd/system/temp*
-rw-r--r-- 1 root root 202 Feb  3  2022 /etc/systemd/system/temperature.service
-rw-r--r-- 1 root root 203 Feb  3  2022 /etc/systemd/system/temperature.service~
-rw-r--r-- 1 root root 134 Aug  9  2021 /etc/systemd/system/temperature.timer

Literally copied, only “my correct script location” replaced by xmessage which does not work lacking display but leaves a message in the log.

systemctl status git-auto.timer
● git-auto.timer - “Run git-auto.sh”
Loaded: loaded (/etc/systemd/system/git-auto.timer; disabled; preset: disabled)
Active: active (waiting) since Mon 2023-12-18 13:03:46 CET; 10s ago
Trigger: Mon 2023-12-18 18:00:00 CET; 4h 56min left
Triggers: ● git-auto.service

What does stat /etc/systemd/system/git-auto.timer say? It should be

Context: system_u:object_r:systemd_unit_file_t:s0

Just taking a guess: SELinux is preventing systemd from reading the file. (If the file was created elsewhere and moved into the folder.)

There are some differences functionality wise. E.g. The unit starts on first login instead of at boot, and units by default does not linger if no user session exists. Basically:[1]

--user
    Talk to the service manager of the calling user, rather than the service manager of the system.

  1. https://www.freedesktop.org/software/systemd/man/latest/systemctl.html#--user ↩︎

I got this :

Context: unconfined_u:object_r:etc_t:s0

i delete the older files and create equally new ones in /etc/systemd/system/user/
editing from there, and got the same error

i run:
systemctl --user start git-auto.timer

didnt get any error, but the timer also didint get listed in systemctl list-timers

yeah bro, i dont know why is not working, im on silverblue dont know if this make any difference
“my correct script location” is the path of my script like /home/…