To run a command inside of another command we can use $( ). What this does is tells bash to evaluate the command or values inside of the parenthesis before evaluating the main command. Other scripting languages such as php use this same format.
The following will run the date command before it runs the echo command. Thus displaying the date inside of the quote.
echo "This is the date $(date)"
Backticks do the same thing.
echo 'This is the date `date`'
Whichever method you use to nest your commands the output is the same: This is the date Wed Mar 8 15:06:49 MST 2017
If we want to we can even redirect this echo to a file.
echo 'This is the date `date`' >> date.txt
cat date.txt
Now that we have a working command we just need to put it in a cronjob. When will the following cron job run? What will it do?
00 06 */5 */2 * echo "This is the date $(date)" >> date.txt
There is no textbook reading for this section.