logoalt Hacker News

Tepixyesterday at 4:00 AM2 repliesview on HN

> But good luck doing that in one line in cron.

Two options:

    0 0 25-31 5 1
or, if your cron supports „L“:

    0 0 L 5 1

Replies

mjmasyesterday at 10:38 AM

Won't your first line mean every Monday in May as well as days 25 to 31 of May?

At least busybox's cron implements it that way:

  if (line->cl_Mins[ptm->tm_min]
  && line->cl_Hrs[ptm->tm_hour]
  && (line->cl_Days[ptm->tm_mday] || line->cl_Dow[ptm->tm_wday])
  && line->cl_Mons[ptm->tm_mon]
  ) {
harshrealityyesterday at 8:25 AM

The first one works in that specific case, but not more generically. For example, "Last Monday in February", or "last Monday of the month" for multiple months unless they're all 30 or all 31 days.

show 1 reply