Linux 使用 crond 定时执行脚本

jopen 10年前
1、创建定时执行文件
每天15点10分执行 app目录下的back_file.sh 文件,该文件用来定时转移备份文件用。
10 15 * * * /app/back_file.sh
将该文件保存名为timedo
2、打开终端
 查看crond的状态
  [root@localhost ~]# service crond status
crond (pid  3788) 正在运行...
将该文件加入定时执行的序列
[root@localhost ~]# crontab /app/timedo
重启crond生效 
[root@localhost ~]# /etc/init.d/crond restart
停止 crond:                                               [确定]
启动 crond:                                               [确定]

重启后静待结果吧。

定时执行 基本格式 :  

* * * * * command 
分 时 日 月 周 命令 
M: 分钟(0-59)。每分钟用*或者 */1表示 
H:小时(0-23)。(0表示0点) 
D:天(1-31)。 
m: 月(1-12)。 
d: 一星期内的天(0~6,0为星期天)。