您的位置:首页 > 运维架构 > Linux

linux系统级定时任务 crontab 研究

2016-07-20 16:46 387 查看
增加定时任务

[root@hdp05 etc]# vi crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

# For details see man 4 crontabs

# Example of job definition:

# .---------------- minute (0 - 59)

# |  .------------- hour (0 - 23)

# |  |  .---------- day of month (1 - 31)

# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...

# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

# |  |  |  |  |

# *  *  *  *  * user-name command to be executed

30 2 * * * root /usr/bin/bbksql_backup backup /data/mysql_backup backup backup 3306 /home/social/my.cnf

*/1 * * * * root /bin/sh /home/crontable/add_partition.sh

0 * * * 1 root /bin/sh /home/crontable/del_partition.sh

,sh 文件可以根据自己习惯放在哪个位置。

查看日志 :

[root@hdp05 etc]# tail -f /var/log/cron 

重启:

[root@hdp05 etc]# service crond restart;

状态:

[root@node4 data]# service crond status;

开始:

[root@node4 data]# service crond start;

结束:

[root@node4 data]# service crond stop;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: