在linux系统上部署脚本并设置定时执行

第一次在公司的服务器上部署了脚本,并且定时执行成功了,记录一下

首先在服务器上编写好python脚本

编写完成后,编写一个shell脚本,在其中设置文件的执行顺序

shell脚本内容如下

bash 复制代码
# 执行query_problematic_data文件
/bin/python3 /home/cmet/edu_recover/query_problematic_data.py
# 执行resand.py文件
/bin/python3 /home/cmet/edu_recover/resand.py
# 执行finished.py文件
/bin/python3 /home/cmet/edu_recover/finished.py

备注:如何知道python文件的运行代码,比较简单的方式是直接在运行python文件,系统会在中断自动显示python文件的运行代码,直接复制到shell脚本中即可

然后赋予shell脚本可执行权限

bash 复制代码
chmod +x run.sh

然后是最关键的一步,通过crontab命令设置shell脚本定时执行

进入编辑

bash 复制代码
crontab -e

编辑定时命令

bash 复制代码
0 6 * * * /home/cmet/edu_recover/run.sh

上述定时命令设置的是每天早上6点中开始执行

相关推荐
hlsd#4 分钟前
我把自己的小米ax3000t换成了OpenWRT
linux·iot
不想画图5 分钟前
Linux——web服务介绍和nginx编译安装
linux·nginx
CIANTECH_Heidi12 分钟前
精准配置重构光模块成本效能:深圳光特通信1X9、SFP单收/单发光模块
运维·服务器·网络·数据库·光模块
2301_8075832320 分钟前
ubuntu22.04集群部署clickhouse详细步骤
linux·clickhouse·zookeeper
尹蓝锐1 小时前
Linux解压各种压缩包命令
linux·运维·服务器
叫致寒吧1 小时前
web和Nginx的搭建
运维·nginx
飞鸡1101 小时前
解决conda环境遇到的qt.qpa.plugin: Could not find the Qt platform plugin “xcb“ in ““问题
服务器·数据库·qt
z***I3942 小时前
Docker书籍
运维·docker·容器
小嘟嘟26792 小时前
Linux-奇怪的No such file or directory
linux·运维·服务器
shizhan_cloud2 小时前
iSCSI 服务器
linux·运维