Crontab + ubuntu + java无法正常工作 [英] Crontab + ubuntu + java not working
问题描述
如果我直接在终端中运行波纹管代码,那就完美了。
/ usr / bin / java -jar /var/jboss-as-7.1.1.Final/standalone/email_linux/notification_18 .jar
但是当我在ubuntu服务器中设置相同的crontab时,它就无法正常工作。
* / 3 * * * * / usr / bin / java -jar /var/jboss-as-7.1.1。 Final / standalone / email_linux / notification_18.jar
任何人都知道为什么出现意外行为?
crontab任务在与您正在测试呼叫的用户不同的用户下执行。 JBoss依赖于许多环境变量,这些变量可能在该上下文中未定义。因此,请从环境中找出特定JAR需要的内容,然后将其添加到从cron任务运行的shell脚本中(而不是直接从cron运行 java
)。 / p>
If I directly run the bellow code in terminal it is working perfect.
/usr/bin/java -jar /var/jboss-as-7.1.1.Final/standalone/email_linux/notification_18.jar
But when I set the same as a crontab in ubuntu server then it is not working.
*/3 * * * * /usr/bin/java -jar /var/jboss-as-7.1.1.Final/standalone/email_linux/notification_18.jar
Any one know why unexpected behavior?
The crontab task is executed under a different user from the one with which you are testing the call. JBoss depends on a number of environment variables, which are probably undefined in that context. So find out what that particular JAR needs from the environment and then add it into a shell script which you run from the cron task (instead of directly running java
from cron).
这篇关于Crontab + ubuntu + java无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!