I have a server set to the UTC time zone. It is running near Sydney and reports are sent to east coast users every day at 4:30PM
When I add a cron job I have to convert from Australia/Sydney time and specify the runtime in UTC time. When daylight savings takes effect in the Australia/Sydney timezone I need to manually change the cronjob in October and April every year.
Display the current system timezone
timedatectl status
#output
Local time: Tue 2025-10-14 11:11:55 UTC
Universal time: Tue 2025-10-14 11:11:55 UTC
RTC time: Tue 2025-10-14 11:11:55
Time zone: UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
Testing the OnCalendar snippet for the .timer file
systemd-analyze calendar 'Mon..Fri 16:30 Australia/Sydney'

Creating the SystemD Service and Timer Files
/etc/systemd/system/dailyreport.service
[Unit]
Description=Send daily report
[Service]
Type=oneshot
ExecStart=/usr/local/bin/senddailyreport
/etc/systemd/system/dailyreport.timer
[Unit]
Description=Run Send Daily Report
[Timer]
OnCalendar=Mon..Fri 16:30 Australia/Sydney
Persistent=true
[Install]
Restart / reload systemctl to get the timer to run
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable --now dailyreport.timer
View the current system timers and when they next will run
systemctl list-timers --all
You can see the dailyreport.timer
will next run in 23h

0 Comments