----------------------------
crontab计划任务
----------------------------
#crontab –l 计划任务列表,查看启用中的任务
#service crond status
#service crond restart
自动启动
#chkconfig crond on
每两分钟执行一次同步
#crontab –e
*/2 * * * * /usr/bin/rsync -vzrtopg --progress --password-file=/etc/rsync.passwd /home/project/Finance/ROOT/u/ sycuser@172.16.0.216::backup
0 2 * * 1-5 /home/apache-tomcat-7.0.79/bin/./shutdown.sh
2 2 * * 1-5 /home/apache-tomcat-7.0.79/bin/./startup.sh
周一到周五,应用凌晨2点重启
0 2 * * 1-5 /home/apache-tomcat-7.0.27/bin/./shutdown.sh
3 2 * * 1-5 /home/apache-tomcat-7.0.27/bin/./startup.sh
#service crond reload
crontab配置
#vi /etc/crontab
执行情况查询
#cd /var/log/
#less cron
或者
#tailf -f /var/log/cron
1.问题及解决方法。
tomcat shudown.sh批处理可以手动执行,但不能再crontab中执行。
1.1 解决手动运行脚本执行正常而放入crontab后不正常的方法
有两种导入方法:
方案1.1.a 在crontab -e编辑时加入
. /etc/profile;/bin/sh #主要"."后要有个空格
0 12 * * * . /etc/profile;/bin/sh /your/sh/your_sh.sh
比如阿里云的服务器配置
0 2 * * 1-5 . /etc/profile;/bin/sh /home/apache-tomcat-7.0.79/bin/./shutdown.sh
1 2 * * 1-5 . /etc/profile;/bin/sh /home/apache-tomcat-7.0.79/bin/./startup.sh
方案1.1.b 在你要运行的脚本的开头加入
source /etc/profile
crontab计划任务
----------------------------
#crontab –l 计划任务列表,查看启用中的任务
#service crond status
#service crond restart
自动启动
#chkconfig crond on
每两分钟执行一次同步
#crontab –e
*/2 * * * * /usr/bin/rsync -vzrtopg --progress --password-file=/etc/rsync.passwd /home/project/Finance/ROOT/u/ sycuser@172.16.0.216::backup
0 2 * * 1-5 /home/apache-tomcat-7.0.79/bin/./shutdown.sh
2 2 * * 1-5 /home/apache-tomcat-7.0.79/bin/./startup.sh
周一到周五,应用凌晨2点重启
0 2 * * 1-5 /home/apache-tomcat-7.0.27/bin/./shutdown.sh
3 2 * * 1-5 /home/apache-tomcat-7.0.27/bin/./startup.sh
#service crond reload
crontab配置
#vi /etc/crontab
执行情况查询
#cd /var/log/
#less cron
或者
#tailf -f /var/log/cron
1.问题及解决方法。
tomcat shudown.sh批处理可以手动执行,但不能再crontab中执行。
1.1 解决手动运行脚本执行正常而放入crontab后不正常的方法
有两种导入方法:
方案1.1.a 在crontab -e编辑时加入
. /etc/profile;/bin/sh #主要"."后要有个空格
0 12 * * * . /etc/profile;/bin/sh /your/sh/your_sh.sh
比如阿里云的服务器配置
0 2 * * 1-5 . /etc/profile;/bin/sh /home/apache-tomcat-7.0.79/bin/./shutdown.sh
1 2 * * 1-5 . /etc/profile;/bin/sh /home/apache-tomcat-7.0.79/bin/./startup.sh
方案1.1.b 在你要运行的脚本的开头加入
source /etc/profile