Cron工作不起作用 [英] Cron Job Not Working

查看:120
本文介绍了Cron工作不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试运行一个简单的shell脚本来执行asl作为回报。我能够手动执行shell脚本,但我无法通过cron作业运行脚本。有人可以帮帮我吗?是否与环境变量有关?我的脚本是


#!/ bin / sh

cd / opt / InCh / IP / smarts / bin

sm_adapter -s APM1 /opt/InCh/IP/smarts/local/rules/Cards.asl>> /opt/InCharge65/IP/smarts/bin/xvz.log


退出0


干杯,

Amit

Hi,

I am trying to run a simple shell script which executes asl in return. I am able to execute the shell scrip manually but i am not able to run the script through cron job. Can anybody help me out? Is it something to do with environment variables?My script is

#!/bin/sh
cd /opt/InCh/IP/smarts/bin
sm_adapter -s APM1 /opt/InCh/IP/smarts/local/rules/Cards.asl >> /opt/InCharge65/IP/smarts/bin/xvz.log

exit 0

Cheers,
Amit

推荐答案





我想跑一个简单的shell脚本,它返回执行asl。我能够手动执行shell脚本,但我无法通过cron作业运行脚本。有人可以帮帮我吗?是否与环境变量有关?我的脚本是


#!/ bin / sh

cd / opt / InCh / IP / smarts / bin

sm_adapter -s APM1 /opt/InCh/IP/smarts/local/rules/Cards.asl>> /opt/InCharge65/IP/smarts/bin/xvz.log


退出0


干杯,

Amit
Hi,

I am trying to run a simple shell script which executes asl in return. I am able to execute the shell scrip manually but i am not able to run the script through cron job. Can anybody help me out? Is it something to do with environment variables?My script is

#!/bin/sh
cd /opt/InCh/IP/smarts/bin
sm_adapter -s APM1 /opt/InCh/IP/smarts/local/rules/Cards.asl >> /opt/InCharge65/IP/smarts/bin/xvz.log

exit 0

Cheers,
Amit



我可以看到你做了一个cd到目录,但是,运行sm_adapter命令前面的完整路径,看它是否有效。


问候,


杰夫

I can see that you did a "cd" to the directory, but instead, run the sm_adapter command with the full path before it and see if it works.

Regards,

Jeff



我可以看到你做了一个cd到目录,但是,运行sm_adapter命令前面的完整路径,看它是否有效。


问候,


杰夫
I can see that you did a "cd" to the directory, but instead, run the sm_adapter command with the full path before it and see if it works.

Regards,

Jeff



您好Jeff,


感谢您的建议。是的,我也尝试过这种方式,但它不起作用。在挫折中,我通过互联网发现,发现很多人都面临这个问题。这与环境变量有关 - shell需要不同的环境变量集,而crontab需要不同。但我无法理解我如何修改我的脚本或更改环境变量。如果你可以通过那边的一些光线,它会很棒!!


干杯,

Amit

Hi Jeff,

Thanks for the suggestions. Yes, i tried that way also but it is not working. In frustation, i serached through the internet and found that many people face this problem. This is something to do with environment variable -- shell takes different set of environment variables and crontab takes different. But i could not understand how i can modify my script or change the environment variables. If you could through some light from that side, it would be great!!

Cheers,
Amit



您好Jeff,


感谢您的建议。是的,我也尝试过这种方式,但它不起作用。在挫折中,我通过互联网发现,发现很多人都面临这个问题。这与环境变量有关 - shell需要不同的环境变量集,而crontab需要不同。但我无法理解我如何修改我的脚本或更改环境变量。如果你可以通过那边的一些光线,它会很棒!


干杯,

Amit
Hi Jeff,

Thanks for the suggestions. Yes, i tried that way also but it is not working. In frustation, i serached through the internet and found that many people face this problem. This is something to do with environment variable -- shell takes different set of environment variables and crontab takes different. But i could not understand how i can modify my script or change the environment variables. If you could through some light from that side, it would be great!!

Cheers,
Amit



如果我没记错的话,当cron作业运行时,它实际上是运行作业的root。这就是为什么需要绝对路径。至于环境变量,如果其中一个没有正确设置,也许你可以在脚本中添加一行来将其更改为你需要的。


问候,


Jeff

If I remember right, when the cron job runs, it is actually root that runs the job. That is why the need for absolute paths. As for the environment variables, if one of them is not getting set correctly, maybe you can put a line in the script to change it to what you need it to be.

Regards,

Jeff


这篇关于Cron工作不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆