Hacker News new | past | comments | ask | show | jobs | submit login

I mostly live in RHEL land so vixie cron was replaced around a decade ago and these days i use systemd, but, i think all of these can be achieved without changing your cron impl:

1. Timezones

    CRON_TZ=Europe/CEST
    0 10 * * * env TZ=America/New York echo “I run at 10am eastern”
    0 10 * * * echo “I run at 10am Central European”
2. Offsets

    0 10 * * 4 [[ date -d "tomorrow" +\%u -lt 8 ]] && echo “I run on the day before the first Friday”
This one is a bit gnarly for a few reasons:

The 4 in the cron spec means Thursday, 0 and 7 mean Sunday.

You can’t use the day of month and day of week fields here as you might (entirely reasonably!) expect. In cron, the other fields are AND together, but day of month and day of week are OR. There are 2 types of people in this world. Those who have been bitten by this and now have this rule tattooed on their brain and those who have yet to be bitten. There isn’t a 3rd type that just read the systemV spec docs… :-)

The % is escaped in the GNU date command because % means new line in cron. Ouch.

3. GNU date shenanigans has you covered here I think.

EDIT: nope, I just tested #1 and this idea doesn’t work. It doesn’t affect the run schedule, it would only impact the timezone of the echo commands here




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: