[systemd-devel] OnCalendar timer starts before the scheduled date has passed

Alden Page alden at creativecommons.org
Mon Mar 4 18:19:05 UTC 2019


Hi systemd team,

I'm having some trouble understanding the behavior of a systemd timer I've
set up in systemd version 219. I have a task that I want to run once per
week on Sundays at 3:00am UTC. However, as soon as I do `systemctl start
my_timer.timer`, the task starts no matter what time it is. This is a
problem for me, because that means that my timer starts every single time I
recreate my server's virtual machine. After the initial erroneously
scheduled job has completed successfully, the timer starts behaving
correctly and runs on Sundays at 3:00am UTC.

Here is how I've set up my timers. This is an excerpt from the script I use
to bootstrap my VMs:

# Schedule weekly ingest of new data
cat << EOF > /etc/systemd/system/ingest_upstream.service
[Unit]
Description=Load and index image data from upstream.
[Service]
ExecStart=/usr/bin/curl -XPOST localhost:8001/task -H "Content-Type:
application/json" -d '{"model": "image", "action": "INGEST_UPSTREAM"}'
EOF

cat << EOF > /etc/systemd/system/ingest_upstream.timer
[Unit]
Description=Ingest data from upstream every Sunday at 8:00am EST (3:00am
UTC).
Requires=ingest_upstream.service

[Timer]
OnCalendar=Sun *-*-* 3:00:00
Unit=ingest_upstream.service

[Install]
WantedBy=timers.target
EOF
systemctl start ingest_upstream.timer

After `systemctl start`, shouldn't it wait until the next OnCalendar
interval has passed, particularly since `Persistent=...` is not set?

Thanks,
Alden
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190304/742019c2/attachment.html>


More information about the systemd-devel mailing list