修改

 

/etc/crontab 

 

0 2 * * * root   nohup /路径/junit_soft1.sh >/路径/nohup1.out &

定时两点执行sh脚本,并将结果后台输出到 nohup1.out

 

 junit_soft1.sh内容如下:

 

 

. /etc/profile

export LIB=/路径/lib

export RUN_PATH=/路径/classes

export CLASSPATH=$LIB/引用的包1.jar:$LIB/引用的包2.jar:$RUN_PATH

java org.junit.runner.JUnitCore com.Test1

 

 

红色那行是要注意的地方,在控执台执行时不需要这行,而在crontab中则要加入这行来构建环境,否则会报"java 找不到"

相关文章: