Linux的例行性工作1

embedded/2024/10/25 6:20:07/

[root@server ~]# vim test2.sh        //编辑脚本

1、每分钟执行命令

[root@server ~]# crontab -e

[root@server ~]# crontab -l
* * * * * sh /root/test2.sh
[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh

[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

2、每小时执行

[root@server ~]# crontab -e

[root@server ~]# crontab -l
0 * * * * sh /root/test2.sh
[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall

3、每天凌晨3点半和12点半执行脚本

[root@server ~]# crontab -e

[root@server ~]# crontab -l
30 3  * * *  sh /root/test2.sh
30 12 * * *  sh /root/test2.sh

[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall

4、每隔6小时,相当于6,12,18,24点半执行脚本

[root@server ~]# crontab -e

[root@server ~]# crontab -l
30 */6 * * * sh  /root/test2.sh

[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall

5、30代表半点,8-18/2表示早上8点到下午18点之间每隔2小时执行脚本

[root@server ~]# crontab -e

[root@server ~]# crontab -l
30 8-18/2 * * * sh /root/test2.sh

[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall

6、每天晚上9点30重启nginx

[root@server ~]# crontab -e

[root@server ~]# crontab -l
30 21 * * * /usr/bin/systemctl restart nginx

[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall

7、每月1和10号凌晨4点45执行脚本

[root@server ~]# crontab -e

[root@server ~]# crontab -l
45 4 1,10 * * sh /root/test2.sh

[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall

8、 每周六和周日凌晨1点10分执行命令

[root@server ~]# crontab -e

[root@server ~]# crontab -l
10 1 * * 6 sh /root/test2.sh
10 1 * * 0 sh /root/test2.sh

[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall

9、每天18点到23点之间,且每隔30分钟执行一次

[root@server ~]# crontab -e

[root@server ~]# crontab -l

0 18-23 * * * sh /root/test2.sh
30 18-23 * * * sh /root/test2.sh

[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall

10、每隔一小时执行一次

[root@server ~]# crontab -e

[root@server ~]# crontab -l

0 * * * * sh /root/test2.sh

[root@server ~]# ls
anaconda-ks.cfg  cro.txt  dead.letter  test2.sh  testcrondtab.sh
[root@server ~]# cat cro.txt

[root@server ~]# crontab -r
[root@server ~]# crontab -l
no crontab for root
[root@server ~]# ps -aux | grep test2

[root@server ~]# killall


http://www.ppmy.cn/embedded/132262.html

相关文章

7、基于爬虫+Flask+Echarts+MySQL的网易云评论可视化大屏

基于爬虫FlaskEchartsMySQL的网易云评论可视化大屏 1、前言2、实现2.1 挑选想要采集的歌曲评论2.2 构建爬虫2.2.1 采集歌曲评论2.2.2 清洗数据入库 2.3 搭建flask框架2.4 数据传值2.5 完整代码&数据集获取 1、前言 本项目是基于requests爬虫flaskecharts搭建的网易云评论的…

Pandas 文件读取与保存指南:高效处理 CSV、Excel 等多种格式数据

Pandas 文件读取与保存指南:高效处理 CSV、Excel 等多种格式数据 本文详细介绍了如何使用 Pandas 的 IO 工具从各种常见文件格式(如 CSV、Excel、HTML、TXT 等)中读取和保存数据。通过 Pandas,用户可以轻松读取和修改数据&#x…

Java-线程池技术

一、线程池简介 线程池是一种池化的思想,是将一些共同资源放到池中进行管理和使用,从而避免大量的创建销毁带来的资源浪费等问题,线程池主要优点体现在: 降低资源消耗:普通线程创建执行完任务之后即被销毁&#xff0…

阿里云用STS上传oss的完整程序执行流程图 和前端需要哪些参数uniapp

H5 微信小程序可用的前端直传阿里云OSS(STS临时凭证前端签名)直接下载插件 下面是原理说明: 明白了,我来详细说明前端上传文件到阿里云OSS需要携带的具体参数: 从服务器获取的 STS 凭证: // 这些参数需要从你的后端服务器获…

从0开始学python-day14-pandas1

一、基础 1、概述 Pandas 是一个开源的第三方 Python 库,从 Numpy 和 Matplotlib 的基础上构建而来 Pandas 名字衍生自术语 "panel data"(面板数据)和 "Python data analysis"(Python 数据分析)…

10.22.2024刷华为OD C题型(三)--for循环例子

脚踝动了手术,现在宾馆恢复,伤筋动骨一百天还真不是说笑的,继续努力吧。 文章目录 靠谱的车灰度图恢复灰度图恢复 -- for循环使用例子 靠谱的车 https://www.nowcoder.com/discuss/564514429228834816 这个题目思路不难,就是要自…

k8s 部署 emqx

安装cert-manager 使用Helm安装 helm repo add jetstack https://charts.jetstack.io helm repo update helm upgrade --install cert-manager jetstack/cert-manager \--namespace cert-manager \--create-namespace \--set installCRDstrue如果通过helm命令安装失败&#x…

gitlab不同账号间·仓库转移

背景:公司业务调整,原先在海外仓库的代码转移回国内 诉求:完整的保留项目记录 操作: 步骤一: 定位到需要迁移的原项目地址 步骤二:创建新项目 步骤三:打开命令行,创建好文件路径为需要clo…