I am having a problem getting my Crontab to work properly.
I'm using the bash shell.
I want to set up a crontab that emails me reports of login activity taken from my auth.log every night.
This is what I have in my crontab -l
I've read that crontab takes minimal environment so I added
/bin/grep and /bin/cat
# m h dom mon dow command
59 23 * * * /bin/cat /var/log/auth.log |/bin/grep "`date \"+%b %e\"`" |mail -s "Testing crontab" firstname.lastname@example.org
But I get nothing.
I've tested everything else, and the problem seems to be when I grep the date. This code works in the command line, but not in Crontab.
I can grep other things, but when I want this specific grep for a specific date, it doesn't work.
Is there something different with Crontab than the shell?
I have no problem if I put this command line into a script and using Crontab to run the script, but I'm just curious as to why crontab wont run the command straight.
Thanks for any input.