Timezone aware cron on Ubuntu 20.04 LTS

Problem: System is running in…

Login

Blog History

Problem: System is running in UTC time zone and I would like to set user cron entries in local time (Australia/Melbourne). It is annoying modifying your cron jobs every 6 months due to daylight savings changes.

Resolution: Install fcron and get time zone aware cronjobs

Download the Dev version of fcron from http://fcron.free.fr/

wget http://fcron.free.fr/archives/fcron-3.3.1.src.tar.gz
tar -xzvf fcron-3.3.1.src.tar.gz
cd fcron-3.3.1
./configure --sysconfdir=/etc # put the config files in /etc
make
# by default it will install binaries to /usr/local
sudo make install 

# answer the questions basically say yes to adding fcron user / groups and install systemd service

As a user

fcrontab -l
2022-02-23 02:03:03  INFO listing myusers's fcrontab
&timezone(Australia/Melbourne) 17 19 * * * echo `date` >> /tmp/date2

# check /tmp/date2 after 5:17PM 

cat /tmp/date2
# output
Tue Feb 8 19:17:00 AEDT 2022
Wed Feb 9 19:17:00 AEDT 2022
Thu Feb 10 19:17:00 AEDT 2022
Fri Feb 11 19:17:00 AEDT 2022
Sat Feb 12 19:17:00 AEDT 2022
Sun Feb 13 19:17:00 AEDT 2022
Mon Feb 14 19:17:00 AEDT 2022
Tue Feb 15 19:17:00 AEDT 2022
Wed Feb 16 19:17:00 AEDT 2022
Thu Feb 17 19:17:00 AEDT 2022
Fri Feb 18 19:17:00 AEDT 2022
Sat Feb 19 19:17:00 AEDT 2022
Sun Feb 20 19:17:00 AEDT 2022
Mon Feb 21 19:17:00 AEDT 2022
Tue Feb 22 19:17:00 AEDT 2022

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.