Linux的例行性工作1

news/2024/10/25 4:43:47/

[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/news/1541744.html

相关文章

Web前端高级工程师培训:使用 Node.js 构建一个 Web 服务端程序(2)

6、返回响应数据(资源) 6-1、使用 http.ServerResponse 类实例处理响应数据(资源) 在每一次的 request 事件中回调函数中会通过参数注入两个对象: 第一个参数: IncomingMessage 对象。第二个参数&#x…

React 项目热更新失效问题的解决方案和产生的原因

背景和意义 在修复React项目热更新失效的问题时,经过一系列问题排查和依赖升级,最终成功修复了问题并为后续开发规避了类似的问题。 依赖升级 Vite版本升级 原React项目Vite版本升级到^4.4.5 Vite 4 在构建和开发服务器的性能上进行了优化&#xff…

【OpenAI】第六节(语音生成与语音识别技术)从 ChatGPT 到 Whisper 的全方位指南

前言 在人工智能的浪潮中,语音识别技术正逐渐成为我们日常生活中不可或缺的一部分。随着 OpenAI 的 Whisper 模型的推出,语音转文本的过程变得前所未有的简单和高效。无论是从 YouTube 视频中提取信息,还是将播客内容转化为文本,…

Leetcode—1242. 多线程网页爬虫【中等】Plus(多线程)

2024每日刷题&#xff08;187&#xff09; Leetcode—1242. 多线程网页爬虫 实现代码 /*** // This is the HtmlParsers API interface.* // You should not implement it, or speculate about its implementation* class HtmlParser {* public:* vector<string>…

Android GPU Inspector分析帧数据快速入门

使用 谷歌官方工具Android GPU Inspector (AGI) 可以对Android 应用进行深入和全面的系统性能分析和帧性能分析 。AGI 是一个非常强大的分析工具&#xff0c;尤其是在需要诊断 GPU 性能问题和优化应用时&#xff0c;可以帮助你精准找到性能瓶颈。本文介绍如何使用该工具对帧数据…

二、Linux 入门教程:开启大数据领域的神奇之旅

Linux 入门教程&#xff1a;开启大数据领域的神奇之旅 在当今这个飞速发展的数字化时代&#xff0c;大数据所具有的重要性正日益凸显出来。而 Linux 作为一种极为强大的操作系统&#xff0c;在大数据这一广阔的领域当中发挥着至关重要、不可或缺的关键作用。倘若你怀有涉足大数…

Kafka 为什么要抛弃 Zookeeper?

嗨&#xff0c;你好&#xff0c;我是猿java 在很长一段时间里&#xff0c;ZooKeeper都是 Kafka的标配&#xff0c;现如今&#xff0c;Kafka官方已经在慢慢去除ZooKeeper&#xff0c;Kafka 为什么要抛弃 Zookeeper&#xff1f;这篇文章我们来聊聊其中的缘由。 Kafka 和 ZooKee…

WebGl 多缓冲区和数据偏移

1.多缓冲区 多缓冲区技术通常涉及到创建多个缓冲区对象&#xff0c;并将它们用于不同的数据集。这种做法可以提高数据处理效率&#xff0c;尤其是在处理大量数据或需要频繁更新数据时。通过预先分配和配置多个缓冲区&#xff0c;可以在不影响渲染性能的情况下&#xff0c;快速…