首先获取企业微信群里的机器人webhook
源码分享
#!/bin/bash
# 定义提醒时间
TipTime="08:50"
TipTimee="18:00"
# 定时提醒
while true; do
# 获取当前时间,与提醒时间作比较,到达提醒时间时发送提醒,否则根据是否是工作日决定睡眠时长
NowTime=$(date +%H:%M)
weekday=$(date +%u)
if [ $weekday -ge 1 ] && [ $weekday -le 5 ]; then
if [ "$NowTime" = "$TipTime" ]; then
curl '写上你自己的webhook地址' -H 'Content-Type: application/json' -d '
{
"msgtype": "text",
"text": {
"content": "上班咯 打卡了哦亲^3^"
}
}'
elif [ "$NowTime" = "$TipTimee" ]; then
curl '写上你自己的webhook地址' -H 'Content-Type: application/json' -d '
{
"msgtype": "text",
"text": {
"content": "下班咯 打卡了哦亲^3^"
}
}'
else
sleep 60s
continue
fi
else
sleep 24h
continue
fi
# 如果不是提醒时间则睡眠60秒
sleep 60s
done
nohup ./test.sh &
此命令 可以把test.sh 脚本放在后台运行 并把输出放在nohup.out文件里
还等什么 还不快去试试