问题描述:
监控脚本手动可以正常执行,但是放到crontab执行失败
问题分析:
1)查看crontab执行日志 (使用root)
vim var/log/cron
2)查看执行日志,发现是调用java执行不了。怀疑是环境变量问题。
3)怀疑crontab有单独的环境变量
cat /etc/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