Crontab是定时任务需要的程序,Debian和Centos的安装方式不一样,现在做下笔记。

1、判断是否安装

直接在shell里输入crontab,如果有显示帮助,则说明安装了。

2、安装

运行

yum -y install vixie-cron
yum -y install crontabs

安装后执行

systemctl start crond.service   #启动程序
systemctl enable crond.service   #设置开机启动
crontab -e  #以当前用户权限编辑定时任务文件
3、管理
启动:
systemctl start crond.service

停止:
systemctl stop crond.service

重启:
systemctl restart crond.service

开机运行:
systemctl enable crond.service

运行状态查看
systemctl status crond.service

Debian、Ubuntu的Crontab在系统里是cron,所以命令和Centos不一样

启动:
systemctl start cron.service

停止:
systemctl stop cron.service

重启:
systemctl restart cron.service

开机运行:
systemctl enable cron.service

运行状态查看
systemctl status cron.service

查看当前用户Crontab任务列表

crontab -l
最后修改:2024 年 01 月 10 日
如果觉得我的文章对你有用,请随意赞赏