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
相关推荐
生信大表哥9 分钟前
如何在服务器上使用 Gemini 3 进行生信分析:从入门到进阶
linux·人工智能·语言模型·数信院生信服务器·生信云服务器
buyutang_19 分钟前
Linux 网络编程:深入浅出UDP协议Socket编程规范
linux·网络·udp
model200520 分钟前
Alibaba linux 3安装LAMP(3)
linux·运维·服务器
JosieBook34 分钟前
【IDEA】IntelliJ IDEA 快捷键大全(Windows/Linux 版)
linux·windows·intellij-idea
赖small强37 分钟前
【Linux 内存管理】Kernel Buddy 分配器:Page Block Size 实现原理与工作机制深度解析
linux·buddy·page block size
robin591143 分钟前
容器-汇总所有环境下的日志排查问题
linux·容器·kubernetes
朗晴1 小时前
Linux修改SSH远程端口号22!
linux·运维·ssh
赖small强1 小时前
【Linux 驱动开发】Linux PWM (脉冲宽度调制) 全面技术指南
linux·驱动开发·pwm
代码游侠1 小时前
Linux系统编程 - 文件操作
linux·运维·服务器·学习
Web极客码2 小时前
CentOS与RHEL安装EPEL源解析错误修复
linux·centos·php