linux系统级定时任务 crontab 研究

来源:互联网 发布:Java restpath 编辑:程序博客网 时间:2024/04/28 22:52


增加定时任务

[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;



0 0