码迷,mamicode.com
首页 > 其他好文 > 详细

centos 7 crontab demo

时间:2017-04-21 23:55:56      阅读:466      评论:0      收藏:0      [点我收藏+]

标签:str   bash   centos   run   shell   home   detail   color   java   

vim /etc/crontab

content

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/jdk1.8.0_131/bin
MAILTO=root
HOME=/opt/refreshIp/target/

*/1 * * * *  ./start.sh
# 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

 

The file named start.sh(./start.sh) and in path "/opt/refreshIp/target/"(HOME)  will be run every minute(*/1 * * * *),in the file, we used java,so that we add "/opt/jdk1.8.0_131/bin" to PATH.

 

systemctl start crond.service

 

WARNNING:Never use "crontab -e",this commond will stop your task,it‘s a bug:  http://stackoverflow.com/questions/34971575/cron-selinux-security-context-issue

centos 7 crontab demo

标签:str   bash   centos   run   shell   home   detail   color   java   

原文地址:http://www.cnblogs.com/flying607/p/6746503.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!