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