It does not run on a Friday the 2nd through the 31st, and it also skips a Saturday or Sunday the 1st, which 0 9 1 * 5 still runs because the day-of-month field matched. So it is not a once-only version of the two-line schedule.
To keep that union and still run once, the day fields in the crontab have to be stars and the check has to live in the command. && and || are left-associative and equal precedence, so this is (day-is-1 OR Friday) and then the job:
date +%u is 1-7, Monday through Sunday, so 5 is Friday. That avoids the crontab quirk where both 0 and 7 mean Sunday while date +%w only ever prints 0.
One test hazard: * * 31 * 3 really is every minute of that Wednesday. Fine for a one-minute check, but the line is live until it is deleted.
0 9 1 * 5 is the union: 09:00 on the 1st and 09:00 every Friday. It is one crontab line, so Friday the 1st still runs once. The two-line version is that same set of days, and both lines match on that morning, so the job runs twice.
The weekday command under that is a smaller set. 0 9 * * 1-5 [ "$(date +%d)" -eq 1 ] && /usr/local/bin/job runs at 09:00 only when the 1st is Monday through Friday. A Friday from the 2nd through the 31st stays quiet, and so does a Saturday or Sunday the 1st. Those two days still run with 0 9 1 * 5, because the day-of-month field matched.
Your command is the union written in the shell, and it still runs once:
Both day fields are stars, so cron fires every day at 09:00 and the command decides. Cron uses sh. There && and || have the same precedence and group left to right, so this is (the day is the 1st, or it is Friday) and then the job. On Friday the 1st the first test succeeds, the Friday test is skipped, and the job runs once.
date +%u is the right weekday test: 1 through 7, Monday through Sunday, so 5 is Friday. %w prints 0 through 6 and never prints 7, while crontab Sunday is both 0 and 7.
Braces make that grouping visible to the next edit:
The single line
0 9 1 * 5is the right collapse: Vixie and cronie OR the two restricted day fields and fire once. The next example is a different set.This only runs when the 1st falls on a weekday:
It does not run on a Friday the 2nd through the 31st, and it also skips a Saturday or Sunday the 1st, which
0 9 1 * 5still runs because the day-of-month field matched. So it is not a once-only version of the two-line schedule.To keep that union and still run once, the day fields in the crontab have to be stars and the check has to live in the command.
&&and||are left-associative and equal precedence, so this is (day-is-1 OR Friday) and then the job:date +%uis 1-7, Monday through Sunday, so 5 is Friday. That avoids the crontab quirk where both 0 and 7 mean Sunday whiledate +%wonly ever prints 0.One test hazard:
* * 31 * 3really is every minute of that Wednesday. Fine for a one-minute check, but the line is live until it is deleted.