cron daemon date/time +4 hours ahead of system date/time on RPI4?

Hi,
I've been using FreeBSD 13.0 on an RPI 4 and I noticed something weird when setting up a cron job. I could not get the cron job to run, so I inspected /var/log/cron and found 2 different datetimes. As you can see below, it logs when I edit the crontab using the correct datetime of the system (the same as what date outputs), then you can also see log entries from /usr/sbin/cron that are +4 hours ahead of the system datetime. So after seeing that, I added 4 hours to my cron job and it ran as expected. I am using NTP for time since the RPI has no hardware clock, and the timezone is set correctly as EST.

Why would the cron daemon be running +4 hours ahead of the system time? Thanks!

Bash:
Jun  6 06:57:00 rpi4-bsd /usr/sbin/cron[11602]: (root) CMD (/root/mtree-specs/mtree-spec-cron-job.sh)
Jun  6 02:57:43 rpi4-bsd crontab[11607]: (root) BEGIN EDIT (root)
Jun  6 02:59:50 rpi4-bsd crontab[11607]: (root) REPLACE (root)
Jun  6 02:59:51 rpi4-bsd crontab[11607]: (root) END EDIT (root)
Jun  6 07:00:00 rpi4-bsd /usr/sbin/cron[1316]: (root) RELOAD (tabs/root)
Jun  6 07:00:00 rpi4-bsd /usr/sbin/cron[11612]: (root) CMD (newsyslog)
Jun  6 07:00:00 rpi4-bsd /usr/sbin/cron[11613]: (operator) CMD (/usr/libexec/save-entropy)
Jun  6 07:00:00 rpi4-bsd /usr/sbin/cron[11614]: (root) CMD (/usr/libexec/atrun)
Jun  6 07:05:00 rpi4-bsd /usr/sbin/cron[11627]: (root) CMD (/usr/libexec/atrun)
 
I suppose, you did check whether your /etc/contab contains any environment variables that might cause this? If I remember correctly, one can change timezone settings for Vixie cron via the TZ environment variable.

Adding something like
Code:
TZ=America/New York
should do the trick of fixing your symptom. Then again this might still not fix the actual underlying issue that's causing your situation. Can't say without seeing what's in your /etc/crontab or in the related files in /etc/crontab.d/.
 
My /etc/crontab is untouched default 13.0, and I have nothing in /etc/crontab.d/. The cron job I added was with crontab -e. I ended up restarting the cron service service cron restart and it seemed to fix the time. I'll see what happens next time I reboot. Thanks.
 
When I run the FreeBSD installer, there's a question I must answer as to whether or not my computer's clock is set to UTC time, or Greenwich Mean Time. UTC time is exactly 4 hours ahead of Eastern Daylight Savings Time, i.e., EDT, or New York time.

I've never had an RPI and am not clear on what the distinction is between a real-time clock and a hardware clock, but all electronic computers require some kind of a hardware clock in order to function. Microsoft Windows expects your hardware clock to be set to local time, whereas Unix derivatives like FreeBSD expect it to be set to UTC.
 
Back
Top