Be careful with `date` and `cron`

One day I write a housekeeping cron job to update me frequently with the status of one of my proxy. Basically I want to put a timestamp on the status report, so I naively put `date +%Y-%b-%d` in the expectation that it will print the date at the time the cron job run.

The result was unexpected, the cron job never run. I scratched my head and tried to do anything within my experience, executing the command from a script and in an Almquish shell, eveything was fine, except when putting it in a cron job.

After a day and a half, I came across a search result that debunk the whole case for me. The character percent `%` need to be escaped (by a backslash `\`) in cron, because percent `%` is a special character to allow the "input" into cron "command" (sixth parameter). So the command that will print the datetime in cron must be `date +\%Y-\%b-\%d`

But there are more than one implementation and more than one version of each implementation of cron, and in each implementation/version, the crontab manpage is written differently. The description can be found from "ISC Cron" `https://linux.die.net/man/5/crontab`, but some of my nodes use "Vixie Cron" and there's no way I can find this information in the manpage.

Proxied content from gemini://tilde.team/~bh/gemlog/006_2022-03-19.gmi (external content)

Gemini request details:

Original URL
gemini://tilde.team/~bh/gemlog/006_2022-03-19.gmi
Status code
Success
Meta
text/gemini; lang=en
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.