Linux Timer task Crond production Java Service manual executable, script not executed case

Source: Internet
Author: User

Linux timed Task crond export variable problem group Friends case

From the Netizen brother Beijing @grady (254553457) Summary.

1) I wrote a restart resin script, due to business reasons, it is necessary to periodically restart the resin server at a certain time, so in
crontab is configured as follows:
50 * * 1-5 root/usr/local/bin/resin_restart.sh
#!/BIN/SH
/usr/local/bin/xxresin_stop.sh
/usr/local/bin/xxresin_start.sh

2) The time of the problem arrived, the server although timed up, but reported the following error:
Resin can ' t load com.sun.tools.javac.Main. Usually this means, the JDK Tools.jar are missing from the classpath,
Possibly because of using a JRE instead of the JDK.
Can either add Tools.jar to the classpath or change the compiler to a external one with <java compiler= ' Javac '/> ; or Jikes.
However, obviously already in profile configuration environment variables, why still can't find it. Toss the demand is not done.

3) Later in the QQ Exchange group 114580181, found the enthusiastic under the old boy teacher, and ask, get the answer is:
Because of the export variable problem: Specifically, crontab can only identify a few system environment variables when executing the shell.
General environment variables are generally unrecognized, and if you need to use variables in the script you write, it is best to use export to re-declare the variable.
To ensure that the script executes correctly. Later as a development basic specification write on.
------------------------
4) Then I redefined the next environment variable in the resin restart script as follows:
#!/bin/sh
#下面就是环境变量定义
Java_home= "/opt/jdk1.6.0_18"
Classpath= $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Path= $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar:/opt/nginx-0.7.61/sbin:/opt/jdk1.6.0_18/bin:/opt/ Resin-3.0.25/bin: $PATH
Export Java_home PATH USER LOGNAME MAIL HOSTNAME histsize INPUTRC CLASSPATH
/usr/local/bin/xxresin_stop.sh
/usr/local/bin/xxresin_start.sh

5) After testing, scheduled tasks at this time successfully restarted, here is very grateful to the old boy teacher to give support.


Linux Timer task Crond production Java Service manual executable, script not executed case

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.