linux 定时执行shell

第一步:安装 crontab ,命令 yum -y install vixie-cron
扩展:service crond start //启动服务
service crond stop //关闭服务
service crond restart //重启服务
service crond reload //重新载入配置
service crond status //查看crontab服务状态
第二步:编写shell文件
要点:1、文件后缀随意它只是存放命令的文件
2、文件中的第一行一定是 #!bin/bash 这行命令 声明这是shel l文件
第三步:添加到定时执行序列中
1、命令行输入 crontab -e 编辑执行序列
2、内容如 40 18 * * * bash /home/worldbackup.sh

                      前5个属性意思分别为  分 时 天 月 周

                      bash 脚本名   // 一种执行脚本的方式

转自https://my.oschina.net/u/3112870/blog/1549724

原文地址:https://www.cnblogs.com/leehom0123/p/14028148.html