Hi Dhar,
the problem in your crontab entry is that the % sign has a special meaning in crontabs. Look carefully at the crontab manual and you will find the explanation:
Quote:
Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
|
hence a correct entry would be:
Code:
58 23 * * * [ $(date +\%d) -eq $(echo $(cal) | awk '{print $NF}') ] && /path/to/myJob.sh
You could take also the suggestion by fpmurphy by simply putting this check at the beginning of your script and execute the rest of the code only if the condition is matched, e.g.
Code:
#!/bin/sh
if [ $(date +%d) -eq $(echo $(cal) | awk '{print $NF}') ]
then
<-- your code here -->
fi
Also don't forget to put full path of your scripts/commands in crontab entries and into the script itself. Indeed, cron has a very limited environment and the PATH is usually limited to /bin:/usr/bin.
Cheers!
PS - I checked the post you refer to... and I forgot to put the backslash before the % sign, there. After more than one year, I can edit it. Thank you for making me notice this "bug".