You are not logged in.
I have a daily service timer pair that work fine if I don't reboot the system. It normally runs at 5:30am. If I have to reboot the PC several times that afternoon the service runs after each reboot. I need to find a solution. Here are the .service and .timer files:
Timer
# This timer unit is for database-backup
[Unit]
Description=start mythtv-database-backup
Requires=mythtv-database-backup.service
[Timer]
Unit=mythtv-database-backup.service
OnCalendar=*-*-* 05:30:00
Persistent=true
[Install]
WantedBy=timers.target
Service
[Unit]
Description=Backup MythTV Database 'mythconverg'
Wants=mythtv-database-backup.timer
Requires=mysql.service
After=mysql.service
After=local-network-pingable.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/mythtv-database-backup.sh
[Install]
WantedBy=multi-user.target
Could this because the Service is enabled? Would the timer only need to be enabled??
Last edited by jfabernathy (2022-01-03 21:50:26)
Offline
Could this because the Service is enabled? Would the timer only need to be enabled??
Correct.
https://wiki.archlinux.org/title/System … rvice_unit
Offline
jfabernathy wrote:Could this because the Service is enabled? Would the timer only need to be enabled??
Correct.
https://wiki.archlinux.org/title/System … rvice_unit
I have read that page and I have disabled the service and only enabled the timer. But when I reboot, the service runs every time. I only want it to run once early in the morning.
Offline
More specifically it's due to the symlink created by the combination of 1) being inabled and 2) the service file having an [Install] section. Why is there even an install section - was this from an AUR package?
EDIT: does the timer status show that it was triggered by the timer, or is something else triggering it at boot up? EDIT 2: see below.
Last edited by Trilby (2022-01-03 21:33:27)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
The second problem is that your timer Requires the service. The timer is activated on boot by timers.target, which then also activates the service.
Last edited by Raynman (2022-01-03 21:33:22)
Offline
The second problem is that your timer Requires the service. The timer is activated on boot by timers.target, which then also activates the service.
You are right removing the requires from the timer solved it. I also removed the install section from the service.
New files:
Service
# This service unit is for backing up the mythtv database called mythconverg
#
[Unit]
Description=Backup MythTV Database 'mythconverg'
Wants=mythtv-database-backup.timer
Requires=mysql.service
After=mysql.service
After=local-network-pingable.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/mythtv-database-backup.sh
Timer
[Unit]
Description=start mythtv-database-backup
[Timer]
Unit=mythtv-database-backup.service
OnCalendar=*-*-* 05:30:00
Persistent=true
[Install]
WantedBy=timers.target
Offline
Thanks for the help. I've rebooted several more times and no triggering of the service.
Offline
All this discussion made me research some more and I wondered why my service had this line in is:
Wants=mythtv-database-backup.timer
The timer is what is triggering the service so at best it's irrelevant. So I removed it and all it still well.
Offline
On a side-note: Since your timer is configured as "persistent", it will also start the corresponding service, if you e.g. boot your machine after 05:30:00. Just be aware of that.
Inofficial first vice president of the Rust Evangelism Strike Force
Offline
On a side-note: Since your timer is configured as "persistent", it will also start the corresponding service, if you e.g. boot your machine after 05:30:00. Just be aware of that.
since this server is on 24/7, it's only the reboot that concerns me
Offline