cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Commander Commander
Commander
  • 563 Views

systemd calendar spec

I want to trigger an event using a systemd timer.  
What systemd calendar specification will trigger
an event everyday, at 7:15am?

Trevor "Red Hat Evangelist" Chandler
Labels (3)
4 Replies
Sunnykumar1
Flight Engineer
Flight Engineer
  • 492 Views

Hello @Trevor 

To trigger a systemd timer every day at 7:15 AM, we can use this calendar specification:

OnCalendar=07:15

 

Systemd assumes:

- Every day

- Seconds = 00

 

Also, here is the fully qualified form:

OnCalendar=*-*-* 07:15:00

 

Year(*)-Month(*)-Day(*) Hour(7):Minute(15):Second(0)

 

Happy Learning

Chetan_Tiwary_
Community Manager
Community Manager
  • 354 Views

@Trevor 

# /etc/systemd/system/trevor.timer
[Unit]
Description=Daily Backup

[Timer]
OnCalendar=*-*-* 07:15:00
Persistent=true

[Install]
WantedBy=timers.target

You can verify this with:

#systemd-analyze calendar "*-*-* 07:15:00"

https://documentation.suse.com/smart/systems-management/html/systemd-working-with-timers/index.html 

https://opensource.com/article/20/7/systemd-calendar-timespans 

Trevor
Commander Commander
Commander
  • 330 Views

# systemd-analyze  calendar  "*-*-* 07:15:00"

This command is so cool!  Being able to verify a specific syntax in 
the unit file, and not the entire unit file itself, is just too cool!!!

Many thanks Chetan!!!

Trevor "Red Hat Evangelist" Chandler
0 Kudos
Priyanshu20041
Flight Engineer
Flight Engineer
  • 238 Views

@Trevor 

To trigger a systemd timer every day at 7:15 AM, use this calendar specification:

# OnCalendar=*-*-* 07:15:00

This runs the associated service once daily at that time.

0 Kudos
Join the discussion
You must log in to join this conversation.