Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass today's date as argument for a cron job

Tags:

date

cron

report

I have a cronjob that will be launched at the end of each month to generate a monthly report.

Here I found how to launch the job at the end of each month: Cron job to run on the last day of the month

Now, I just want the date of the last day of the month as an argument for the script.

For example:

compute_monthly_rate -e **2016.01.31**

How can I pass this date as an argument?

like image 311
Nokali Avatar asked Dec 24 '22 09:12

Nokali


1 Answers

Most implementations of cron pass a command string to /bin/sh so depending on what it is on your system and what implementation of date you have you may have luck with this:

compute_monthly_rate -e $(date +%Y.%m.%d)

Try it in a terminal first:

$ date +%Y.%m.%d
2016.02.02
like image 68
Arkadiusz Drabczyk Avatar answered Dec 27 '22 10:12

Arkadiusz Drabczyk