shell脚本不通过crontab运行,手动运行良好 [英] shell script not running via crontab, runs fine manually
问题描述
我已经尝试导出我的路径和变量,crontab仍然不会运行我的脚本。我相信我做错了。
I have tried exporting my paths and variables and crontab still will not run my script. I'm sure I am doing something wrong.
我有一个运行jar文件的shell脚本。这不正常工作。
I have a shell script which runs a jar file. This is not working correctly.
阅读完之后,我读过这通常是由于不正确的路径,由于cron通过自己的shell实例运行,因此没有与我的配置文件相同的首选项设置
After reading around I have read this is commonly due to incorrect paths due to cron running via its own shell instance and therefore does not have the same preferences setup as my profile does.
这里是我的脚本在几个修改后看起来像今天:
Here is what my script looks like today after several modifications:
#!/bin/bash --
. /root/.bash_profile
/usr/bin/java -jar Pharmagistics_auto.jar -o
...
这些是脚本最重要的部分,其他都是直接基于shell的。
those are the most important pieces of the script, the rest are straightforward shell based.
告诉我我在做什么错误?
Can someone tell me what I am doing wrong?
推荐答案
尝试指定jar文件的完整路径:
Try specifying the full path to the jar file:
/usr/bin/java -jar /path/to/Pharmagistics_auto.jar -o
这篇关于shell脚本不通过crontab运行,手动运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!