I have a problem using the linux 'date' command within a cronjob.
Linux version: CentOS Linux 7 (Core)
What i need is the date of 9 days ago as a parameter to my test.sh script. Today is 10-08-2016, the job that needs to be executed is:
/scripts/test.sh 2016-08-01
My code in crontab:
DATEVAR=$(date +%F --date="9 days ago")
0 12 * * tue ~/scripts/test.sh $($DATEVAR)
So the linux command is 'date +%F --date="9 days ago"' but i need this to be executed and set as parameter. What it does now is run the script with as parameter '$(date':
~/scripts/test.sh $(date
I have tried setting the DATEVAR with the following things without succes:
DATEVAR='date +%F --date="9 days ago"'
DATEVAR=date +%F --date="9 days ago"
DATEVAR=$(date +%F --date="9 days ago")
DATEVAR=(shell date +%F --date="9 days ago")
Does anyone know if this is possible and how my DATEVAR can be set with the result of executing the 'date' command?