金融投资网站模板策划公司职位
web/
2025/10/7 15:51:48/
文章来源:
金融投资网站模板,策划公司职位,怎么样做网站页面,wordpress连不上mysql8CentOS 使用 Cronie 实现定时任务 文章目录 CentOS 使用 Cronie 实现定时任务一、简介二、基本使用1、常用命令2、使用示例第一步#xff1a;创建脚本/home/create.sh第二步#xff1a;添加定时任务第三步#xff1a;重启 cronie 服务额外#xff1a;查看 cronie 运行状态定…CentOS 使用 Cronie 实现定时任务 文章目录 CentOS 使用 Cronie 实现定时任务一、简介二、基本使用1、常用命令2、使用示例第一步创建脚本/home/create.sh第二步添加定时任务第三步重启 cronie 服务额外查看 cronie 运行状态定时任务执行结果参考 3、其它 一、简介
Cronie 是 CentOS 中用于配置定时任务的工具。它可以周期性地执行指定的命令或脚本。Cronie 由两个部分组成
crond守护进程负责检查和执行定时任务。crontab配置文件用于定义定时任务。
二、基本使用
1、常用命令
# 安装 cronie
sudo yum install cronie# 启动 cron 服务
sudo systemctl start crond# 重启 cron 服务
sudo systemctl restart crond# 查看 cron 状态
sudo systemctl status crond# 查看 cron 任务
crontab -l# 编辑/删除 cron 任务
# 要删除一个 cron 任务你可以编辑 /etc/crontab 文件或者 /etc/cron.d/ 目录下的文件或者使用 crontab -e 命令来编辑当前用户的cron任务。
crontab -e2、使用示例
第一步创建脚本/home/create.sh
#!/bin/bash
# 创建一个包含当前时间戳的.txt文件
TIMESTAMP$(date %Y%m%d%H%M%S)
FILENAMEtimestamp_${TIMESTAMP}.txt
echo Current timestamp: ${TIMESTAMP} /home/${FILENAME}第二步添加定时任务
# 打开任务编辑器
crontab -e# 命令内容
* * * * * /home/create.sh第三步重启 cronie 服务
sudo systemctl restart crond额外查看 cronie 运行状态
sudo systemctl status crond定时任务执行结果参考
[rootVM-0-11-centos home]# ls -l
总用量 80
-rwxrwxrwx 1 root root 193 4月 1 14:16 create.sh
-rw-r--r-- 1 root root 34 4月 1 14:13 timestamp_20240401141301.txt
-rw-r--r-- 1 root root 34 4月 1 14:14 timestamp_20240401141401.txt
-rw-r--r-- 1 root root 34 4月 1 14:15 timestamp_20240401141501.txt
-rw-r--r-- 1 root root 34 4月 1 14:16 timestamp_20240401141601.txt
-rw-r--r-- 1 root root 34 4月 1 14:17 timestamp_20240401141701.txt
-rw-r--r-- 1 root root 34 4月 1 14:18 timestamp_20240401141801.txt
-rw-r--r-- 1 root root 34 4月 1 14:19 timestamp_20240401141901.txt
-rw-r--r-- 1 root root 34 4月 1 14:20 timestamp_20240401142001.txt
-rw-r--r-- 1 root root 34 4月 1 14:21 timestamp_20240401142101.txt
-rw-r--r-- 1 root root 34 4月 1 14:22 timestamp_20240401142201.txt
-rw-r--r-- 1 root root 34 4月 1 14:23 timestamp_20240401142301.txt
-rw-r--r-- 1 root root 34 4月 1 14:24 timestamp_20240401142401.txt
-rw-r--r-- 1 root root 34 4月 1 14:25 timestamp_20240401142501.txt
-rw-r--r-- 1 root root 34 4月 1 14:26 timestamp_20240401142601.txt
-rw-r--r-- 1 root root 34 4月 1 14:27 timestamp_20240401142701.txt
-rw-r--r-- 1 root root 34 4月 1 14:28 timestamp_20240401142801.txt
-rw-r--r-- 1 root root 34 4月 1 14:29 timestamp_20240401142901.txt
-rw-r--r-- 1 root root 34 4月 1 14:30 timestamp_20240401143001.txt3、其它
注意权限问题
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/88560.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!