You are not logged in.
Hello,
I've tried to follow the wiki's systemd/cron functionality article to have a systemd service to run hourly.
Everything seems to be working ok, except that the hourly timer doesn't start automatically : I have to issue a
systemctl --user timer-hourly.timer startcommand every time I start the machine to get the timer running.
Can you help me understand what I'm missing to get the (user) timer to start automatically after boot?
Thanks!
---------------------------------------------------
My setup consists of the following files:
/home/myuser/.config/systemd/user:
drwxr-xr-x 2 myuser users 4096 Jun 25 17:30 basic.target.wants/
-rw-r--r-- 1 myuser users 217 Jun 25 10:08 db_backup.service
-rw-r--r-- 1 myuser users 232 Jun 25 10:08 test.service
-rw-r--r-- 1 myuser users 61 Jun 19 12:14 timer-hourly.target
drwxr-xr-x 2 myuser users 4096 Jun 25 10:10 timer-hourly.target.wants/
-rw-r--r-- 1 myuser users 134 Jun 19 12:14 timer-hourly.timer/home/myuser/.config/systemd/user/basic.target.wants/:
lrwxrwxrwx 1 myuser users 50 Jun 25 10:08 timer-hourly.timer -> /home/myuser/.config/systemd/user/timer-hourly.timer/home/myuser/.config/systemd/user/timer-hourly.target.wants/:
lrwxrwxrwx 1 myuser users 49 Jun 13 15:51 db_backup.service -> /home/myuser/.config/systemd/user/db_backup.service
lrwxrwxrwx 1 myuser users 44 Jun 25 10:10 test.service -> /home/myuser/.config/systemd/user/test.servicetimer-hourly.timer:
[Unit]
Description=Hourly Timer
[Timer]
OnBootSec=5min
OnCalendar=hourly
Unit=timer-hourly.target
[Install]
WantedBy=basic.targettimer-hourly.target:
[Unit]
Description=Hourly Timer Target
StopWhenUnneeded=yestest.service:
[Unit]
Description=Run a test (echo) job every hour
Wants=timer-hourly.timer
[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/usr/bin/python /home/myuser/test_service.py
[Install]
WantedBy=timer-hourly.targetdb_backup.service:
[Unit]
Description=Backups databases
Wants=timer-hourly.timer
[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/home/myuser/source/db_backups/db_backup.sh
[Install]
WantedBy=timer-hourly.targettest_service.py is a simple python script that appends the current time to a file, to check if the service is being run by the timer. (it is after I start the timer after boot, and runs correctly every hour)
db_backup.sh is a script that dumps a database into a text file in a mercurial repository, commits the change and pushes it to backup locations.
Last edited by fede (2014-06-25 21:06:09)
Offline
Have you tried this:
systemctl --user enable timer-hourly.timer"Only wimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it."—Linus Torvalds
s/ftp/git/
https://iandouglasscott.com | https://github.org/ids1024 | https://keybase.io/ids1024
Offline
That's it!
Thanks a lot!
Offline