linux bash shell http请求脚本

/opt/refreshCache/refreshCache.sh

复制代码
[umed@VM-0-14-centos logspayment]$ more /bin/bash /home/umed/opt/refreshCache/refreshCache.sh

******** /bin/bash: Not a text file ********

::::::::::::::
/home/umed/opt/refreshCache/refreshCache.sh
::::::::::::::
#!/bin/bash

# 定义接口地址
URL1="https://hlwyy.yy.com/rbu/open/uipHttp/refresh?hospitalId=&uhospitalId=81d6ee37-afc3-4625-8720-ee916a6ebeb1"
URL2="https://hlwyy.yy.com/ibh/consultapi//config/hospitalConfig/updateConfig?unionId=33&hospitalId=1120010613414232310"

# 定义日志文件路径,下方的 /path/to/your/logfile.log 需要改成自己项目上的路径,切记!
LOG_FILE="/home/umed/opt/refreshCache/logfile.log"

# 定义函数,用 curl 发送请求,并打日志
function send_request {
    URL=$1
    echo "Sending GET request to $URL" >> $LOG_FILE
    RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" $URL)
    if [ $RESPONSE -eq 200 ]; then
        echo "Successfully refreshed $URL at $(date)" >> $LOG_FILE
    else
        echo "Failed to refresh $URL at $(date). HTTP response code: $RESPONSE" >> $LOG_FILE
    fi
}

# Send GET requests
send_request $URL1
send_request $URL2

定时任务crontab

复制代码
[umed@VM-0-14-centos logspayment]$ sudo crontab -u root -l
*/5 * * * * flock -xn /tmp/stargate.lock -c '/usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &'
0 0 * * * /bin/bash /home/umed/opt/refreshCache/refreshCache.sh
相关推荐
超人不会飛8 分钟前
就着HTTP聊聊SSE的前世今生
前端·javascript·http
小张不嚣张꒰ঌ(˚ᆺ˚)໒꒱1 小时前
Centos7在yum当中遇到Could not resolve host: mirrorlist.centos.org解决方案
linux·运维·服务器·centos
Sally璐璐1 小时前
CentOS企业级文件服务器终极部署指南
linux·服务器·centos
岁月玲珑1 小时前
【如何判断Linux系统是Ubuntu还是CentOS】
linux·ubuntu·centos
梅孔立1 小时前
yum update 报错 Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64 等解决办法
linux·python·centos
ldj20201 小时前
Centos 安装Jenkins
java·linux
Sca_杰1 小时前
centos指令
linux·运维·centos
几道之旅1 小时前
centos 7 安装NVIDIA Container Toolkit
linux·运维·centos
DuelCode1 小时前
Windows VMWare Centos Docker部署Nginx并配置对Springboot应用的访问代理
linux·运维·服务器
数据智能老司机1 小时前
Linux内核编程——网络驱动程序
linux·架构·操作系统