linux 添加定时任务 带动态日期
*/1 * * * * /usr/local/shell/shell_gs/start_task.sh product $(date +"\%Y-\%m-\%d" -d "-9day") 19 19 1 >> /home/log/product_`date +"\%Y\%m\%d"`.log 2>&1
获取指定日期的前一天
echo `date -d"1 day ago ${ymd}" +%Y-%m-%d`
today=`date +%Y%m%d`
echo $today
获取星期几
whichday=`date -d $today +%w`
echo $whichday
#周一日期
monday=`date -d "$today -$[${whichday}-1] days" +%Y%m%d`
echo $monday
if [ "$today" == "$monday" ] then
echo "周一"
fi
#上个月第一天
firstday=`date -d "-1 month -$(($(date +%d)-1)) days" +%Y%m%d`
echo $firstday
#上个月最后一天
lastday=`date -d "-$(date +%d) days" +%Y%m%d`
echo $lastday
first_month_day=`date +%Y%m01`
echo $first_month_day
#月第一天
if [ "$first_month_day" =="$today" ]
echo "月初"
fi