You are not logged in.
Hi everybody.
I creted in $HOME/.config/systemd/user/ 3 files:
my_timer.timer
my_timer.service
backup_script.sh
code my_timer.timer:
[Unit]
Description=Run every day for backup some folders to cloud
After=timer-sync.target
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timer.target
code my_timer.service:
[Unit]
Description=service for timer
[Service]
Type=simple
ExecStart=/home/user/.config/systemd/user/backup_script.sh
Code of backup_script.sh does not matter.
Then I did:
$ systemctl --user daemon-reload
$ systemctl --user enable my_timer.timer
$ systemctl --user start my_timer.timer
After this manipulation all is Ok. My timer appeared in the:
$ systemctl --user timers-list
But after reboot I checked timers-list and did not find there my timer. After I checked status of timer and service:
$ systemctl --user status my_timer.timer
my_timer.timer - Run every day for backup some folders to cloud
Loaded: loaded (/home/user/.config/systemd/user/my_timer.timer; enabled; vendor preset: enabled)
Active: inactive (dead)
$ systemctl --user status my_timer.service
my_timer.service - service for timer
Loaded: loaded (/home/user/.config/systemd/user/my_timer.service; static; vendor preset: enabled)
Active: inactive (dead)
Then I checked log for timer:
$ journalctl --user-unit my_timer.timer
...
jul 10 18:03:02 comp systemd[580]: Started Run every day for backup some folders to cloud.
jul 10 18:03:02 comp systemd[580]: Starting Run every day for backup some folders to cloud.
jul 10 18:04:11 comp systemd[580]: Stopped Run every day for backup some folders to cloud.
jul 10 18:04:11 comp systemd[580]: Stopping Run every day for backup some folders to cloud.
I do not understant it. Why systemd start my timer, then stop it after 1 minute? WAIDW?
Last edited by StonedAstronaut (2015-07-11 07:49:36)
Offline
Try:
[Unit]
Description=Run every day for backup some folders to cloud
#After=time-sync.target
[Timer]
OnCalendar=daily
Persistent=true
#[Install]
#WantedBy=timers.target
Last edited by berbae (2015-07-10 21:33:48)
Offline
Try:
[Unit] Description=Run every day for backup some folders to cloud #After=time-sync.target [Timer] OnCalendar=daily Persistent=true #[Install] #WantedBy=timers.target
If you remove the [Install], the timer will not load on reboot. I don't use timers.target, I use default.target and I've:
# loginctl enable-linger username
edit: but after googling a bit, I think I'll change my [Install] to WantedBy=timers.target
Last edited by Buddlespit (2015-07-11 01:19:00)
Offline
Try:
[Unit] Description=Run every day for backup some folders to cloud #After=time-sync.target [Timer] OnCalendar=daily Persistent=true #[Install] #WantedBy=timers.target
Hi. Thank you for answer.
Directive After= is recommend by systemd man.
...
Timer units with at least one OnCalendar= directive will have an additional After= dependency on timer-sync.target to avoid being started before the system clock has been correctly set.
...
WantedBy=timers.target I took from archwiki.
Last edited by StonedAstronaut (2015-07-11 06:28:40)
Offline
# loginctl enable-linger username
I tried this command. But it has no effect. After reboot I check:
$ systemctl --user list-timers
0 timers listed.
Pass --all to see loaded but inactive timers, too.
$ systemctl --user status my_timer.timer
● my_timer.timer - Run every day for backup some folders to cloud
Loaded: loaded (/home/user/.config/systemd/user/my_timer.timer; enabled; vendor preset: enabled)
Active: inactive (dead)
Maybe is it a bug in systemd? I will check the same configuration on another distro with systemd.
Last edited by StonedAstronaut (2015-07-11 06:45:19)
Offline
Directive After= is recommend by systemd man.
...
Timer units with at least one OnCalendar= directive will have an additional After= dependency on timer-sync.target to avoid being started before the system clock has been correctly set.
...
It says that dependency is implicit when you have at least one OnCalendar directive, so you don't have to add it yourself.
WantedBy=timers.target I took from archwiki.
Yes, that's good, but you had a typo: timer.target without the 's'. I don't expect that to be the cause of this (I don't know what it could be), but make sure to check it anyway.
Offline
...
Yes, that's good, but you had a typo: timer.target without the 's'. I don't expect that to be the cause of this (I don't know what it could be), but make sure to check it anyway.
Yes you are right. This is typo. I have to be careful in next time.
Thanks for all. This "problem" is solved.
PS: Maybe systemd must log such errors?
Offline