crontab 添加sh文件定时

(1)编写sh文件,比如/orcl/test/export.sh

      编写crond文件

      chmod 755 /orcl/test/*      //复制所有权限

        [root@postest test]# vi crond.txt
         19 18 * * * sh  /orcl/test/cpfile.sh

(2)上传到/opt目录 

       [root@postest test]# cp /orcl/test/crond.txt /opt/
(3)运行命令 
crontab /opt/crond.txt 
crontab –l 
让配置文件生效:如果让配置文件生效,还得重新启动cron,切记,既然每个用户下的cron配置文件修改后,也要重新启动cron服务器。 

[root@postest test]# service crond restart
Stopping crond: [ OK ]
Starting crond:


如果让crond在开机时运行,应该改变其运行级别: 
chkconfig –level 35 crond on 
service crond status查看cron服务状态,如果没有启动则service crond start启动它,cron服务是一个定时执行的服务,可以通过crontab命令添加或者编辑需要定时执行的任务

原文地址:https://www.cnblogs.com/fenglan/p/5917593.html