
사용자 의 경우 root
crontab에 대한 JAVA_HOME 변수를 다음과 같이 구성했습니다.
[root@localhost ~]# vim /etc/crontab
_______
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/jdk1.8.0_71/bin
MAILTO=root
JAVA_HOME=/opt/jdk1.8.0_71
_______
다음 이름 을 가진 다른 사용자가 실행하는 cronjob을 정의했습니다 tomcat
.
[tomcat@localhost ~]$ crontab -e
_______
30 10 * * * /opt/tomcat/bin/shutdown.sh >> /opt/tomcat/logs/cron_restart.log 2>&1
32 10 * * * /opt/tomcat/bin/startup.sh >> /opt/tomcat/logs/cron_restart.log 2>&1
_______
작업이 실행 중이지만 내 로그에 다음이 표시됩니다.
[tomcat@localhost ~]$ vim /opt/tomcat/logs/cron_restart.log
______
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
______
1.) crontab이 JAVA_HOME을 얻지 못하는 이유는 무엇입니까?
2.) JAVA_HOME이 어디에 있는지 crontab에 알릴 수 있는 가능성은 무엇입니까?
내 접근 방식은 이 페이지의 CentOs-Docs를 기반으로 합니다. https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-autotasks-cron-configuring.html
3.) 제가 문서를 잘못 읽었을 수도 있나요?
답변1
이것이 내가 일하는 방식입니다:
파일에 다음 줄을 삽입합니다 /opt/tomcat/bin/setenv.sh
.
export JAVA_HOME="/opt/jdk1.8.0_71"