1. 创建钉钉群,并添加机器人
自行百度
2. 编写提醒内容文件(dingding.txt)
第一行是webbook url
其他每行是一条提醒消息:消息不同部分使用:::分隔,包括日期、关键字、提醒内容(markdown样式)
dingding.txt内容如下:

3. 编写shell脚本sprint.sh,读取dingding.txt,根据日期发送群消息
#!/bin/bash
if [ $# -lt 1 ];then
echo "please input message file...";
exit;
fi
cur_dir=$(dirname $(readlink -f $0))
cd $cur_dir;
msgfile=$1;
webhookurl=`grep "webhook===" $msgfile | awk -F'===' '{print $2}'`
echo "webhookurl=$webhookurl"
todaystr=`date "+%Y-%m-%d"`
grep -v 'webhook===' $msgfile | while read line
do
setdaystr=`echo "$line" | awk -F':::' '{print $1}'`;
if [ "$todaystr" != "$setdaystr" ]
then
echo "------------> $setdaystr";
continue;
fi
title=`echo "$line" | awk -F':::' '{print $2}'`;
msg=`echo "$line" | awk -F':::' '{print $3}'`;
#msg=`echo $msg | sed 's/\\n/\n/g'`
#tipmsg=`echo -e '{"msgtype": "markdown","markdown": {"title": "'"$title"'","text": "### '"$title"'\n\n'"$msg"'\n\n> (*^-^*)"},"at": {"isAtAll": 1}}'`;
#echo $tipmsg
curl "$webhookurl" \
-H 'Content-Type: application/json' \
-d '{"msgtype": "markdown","markdown": {"title": "'"$title"'","text": "# **'"$title"'**\n\n'"$msg"'\n\n> (*^-^*)"},"at": {"isAtAll": 1}}'
done
4. 配置crontab定时任务,每天9:30分执行脚本
30 9 * * * root /xxx/dingding/sprint.sh sprints_cycle/dingding.txt