The cal command produces a calendar like this
Code:
July 2008
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
The statement echo `cal` (backticks for command substitution) put the above output on one-line. Better to use the $(...) syntax for command substitution, which permits nesting without escaping the backticks (as in your command line). So
Code:
$ echo $(cal)
July 2008 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
This output is piped to the awk command which simply extract the last blank-space-separated field of the above line, that is the last day of the month:
Code:
$ echo $(cal) | awk '{print $NF}'
31
The output of the date command, which gives the day of the months, is compared with the output above. So the test is true if the current day is equal to the last day of the current month. The test is embedded in square brackets. If the result of the test is true, the command/script myJob.sh is executed. This is the meaning of the && sign.
In summary your crontab entry can be written as
Code:
58 23 * * * [ $(date +\%d) -eq $(echo $(cal) | awk '{print $NF}') ] && myJob.sh
using the $(...) notation for command substitution.