我在14.04.1-Ubuntu上运行这个
3.19.0-56-通用#62~14.04.1-Ubuntu Mar11:03:15 UTC 2016 x86_64 GNU/Linux
使用java版本:
java版本"1.7.0_80“Java(TM) SE运行时环境(build 1.7.0_80-b15) Java HotSpot(TM) 64位服务器VM (build 24.80-b11,混合模式)
所以在我的cron发情器和delme.jar中有两个元素。
PATH=/usr/bin/java:/usr/bin/javac:/usr/lib/jvm/java-7-oracle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v85/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v85/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v85/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/$
XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Runtime/v85/X11/app-defaults:/usr/local/MATLAB/MATLAB_Runtime/v90/X11/app-defaults
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
5,10,15,20,30,35,40,43,45,50,52,55,58 * * * 0,1,2,3,4,5,6 /home/meh/model/TestModelABC/testrun > /home/meh/model/TestModelABC/testrun.log
5,10,13,15,17,18,20,25,30,33,35,36,40,43,45,50,52,55,58 * * * 0,1,2,3,4,5,6 java -jar /home/meh/model/TestModelABC/delme.jar > /home/meh/model/TestModelABC/del.logtestrun是一个bash脚本,它按如下方式调用java代码:
#!/bin/sh
java -jar delme.jar这不管用。当我从crontab中直接通过java -jar delme.jar调用文件时,它也不起作用。
我知道cron正在运行它,只是不执行java。
为此,您可以看到,将路径放到crontab的路径中,并尝试将路径放入bash脚本中,如下所示:
PATH=/usr/bin/java:/usr/bin/javac:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v85/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v85/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v85/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/os/glnxa64:
XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Runtime/v85/X11/app-defaults:/usr/local/MATLAB/MATLAB_Runtime/v90/X11/app-defaults
echo "Forecast Test"我现在真的被困住了,因为我没有办法去尝试。有什么想法吗?我的直觉告诉我,这是一个路径问题,但我不知道还有什么值得尝试。
发布于 2016-04-04 12:28:31
事实证明,这是一个路径问题,CRON从/home/user调用,因此在-cp中使用的任何相关路径都不再工作。
发布于 2016-03-31 21:20:50
当我通过java -jar delme.jar直接调用文件时,它也不起作用
听起来好像您没有可执行的jar文件。
确保在jar清单中设置了Main-Class: classname,或者直接运行类,在类路径上指定jar。
例如java -cp delme.jar path.to.package.Main
https://stackoverflow.com/questions/36343768
复制相似问题