Skip navigation

Monthly Archives: Desember 2014


So I some times need to run a monthly cron job. And I want to set a parameter for duration spanned from first day and last day in the current month.

This is how I do it.

if [ -z “$STARTTIME” ] || [-z “$ENDTIME”]; then
STARTTIME=`date -d “-$(($(date +%d)-1)) days” +%Y-%m-%dT00:00:00Z`;
ENDTIME=`date -d “+1 month -$(date +%d) days” +%Y-%m-%dT23:59:59Z`;
fi

echo $STARTTIME
echo $ENDTIME

Iklan
%d blogger menyukai ini: