Cron job delayed by ~1 second

I am running the following cron job

* * * * * date "+\%Y\%m\%dT\%H\%M\%S" > /path/to/log 2>&1

but it's running around a second too late, as it writes e.g.

20210817T210001

How can I ensure the cron job will run at the full minute?


This is also covered over at Server Fault.

I personally favor this quote: "What cron can guarantee is that your job will start no sooner than the specified time." In other words, cron isn't really designed to be surgically precise to the second. Most of my own cron jobs will also start at 01 or even 02 seconds after the full minute.

In order for cron jobs to start, cron will scan what jobs need to run at any given time. It's not an error if a job scheduled to start at 12:00:00 will actually start at 12:00:01, since the amount of time for cron to initialize can vary, depending on a number of factors.

If you need something to trigger "almost" (thanks Kevin) at the exact second, you should look for another solution than cron - for instance systemd timers (thanks Andrej), a Python script or even a C program that monitors the time for you.

EDIT: Alternately (as suggested by Nonny Moose), you can schedule a script to run one minute early, and then monitor the time so it runs as precise as possible when you want it to run.