You are not logged in.

#1 2017-12-05 11:50:24

ralpheeee88
Member
Registered: 2015-04-19
Posts: 30

[Solved] systemd service / timers help

I am attempting to to create a weekly systemd service but have noticed on boot the service runs immediately. looking to avoid that the services runs each time i boot up

 
● rsync-home.service - rsync-home weekly backup
   Loaded: loaded (/etc/systemd/system/rsync-home.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Tue 2017-12-05 12:20:24 CET; 25min ago
 Main PID: 700 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/rsync-home.service

Dec 05 12:20:20 p50 systemd[1]: Starting rsync-home weekly backup...
Dec 05 12:20:20 p50 sudo[707]: ralpheeee : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/rsync -aAXv --delete --e
Dec 05 12:20:20 p50 home.sh[700]: sending incremental file list
Dec 05 12:20:20 p50 sudo[707]: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec 05 12:20:20 p50 home.sh[700]: ./
Dec 05 12:20:20 p50 home.sh[700]: .config/mutt/mailboxes
Dec 05 12:20:24 p50 home.sh[700]: sent 245,532 bytes  received 1,933 bytes  54,992.22 bytes/sec
Dec 05 12:20:24 p50 home.sh[700]: total size is 4,294,841,397  speedup is 17,355.35
Dec 05 12:20:24 p50 sudo[707]: pam_unix(sudo:session): session closed for user root
Dec 05 12:20:24 p50 systemd[1]: Started rsync-home weekly backup.
 

[Unit]
Description=rsync-home weekly backup
StopWhenUnneeded=yes

[Service]
Type=oneshot
User=ralpheeee
ExecStart=/home/ralpheeee/.scripts/rsync/home.sh

[Install]
WantedBy=multi-user.target
[Unit]
Description=rsync-home weekly backup

[Timer]
OnCalendar=Sun *-*-* 09:05:00
Persistent=True

Unit=rsync-home.service

[Install]
WantedBy=multi-user.target

Last edited by ralpheeee88 (2017-12-05 12:21:41)

Offline

#2 2017-12-05 12:03:42

positronik
Member
Registered: 2016-02-08
Posts: 95

Re: [Solved] systemd service / timers help

Did you enable the timer or the service?

Offline

#3 2017-12-05 12:10:34

ralpheeee88
Member
Registered: 2015-04-19
Posts: 30

Re: [Solved] systemd service / timers help

i enabled both the timer and the service

positronik wrote:

Did you enable the timer or the service?

Offline

#4 2017-12-05 12:16:19

TheSpiritof69
Member
Registered: 2015-03-14
Posts: 7

Re: [Solved] systemd service / timers help

man systemd.timer wrote:

OnActiveSec=, OnBootSec=, OnStartupSec=, OnUnitActiveSec=, OnUnitInactiveSec=
Defines monotonic timers relative to different starting points: OnActiveSec= defines a timer relative to the moment the timer itself is activated. OnBootSec= defines a timer relative to when the machine was booted up. OnStartupSec= defines a timer relative to when systemd was first started. OnUnitActiveSec= defines a timer relative to when the unit the timer is activating was last activated. OnUnitInactiveSec= defines a timer relative to when the unit the timer is activating was last deactivated.

man systemd.timer

You want OnUnitActiveSec too.

Last edited by TheSpiritof69 (2017-12-05 12:23:57)

Offline

Board footer

Powered by FluxBB