Monday, June 22, 2015

bash - Script is not able to execute the commands from crontab



I am facing a weired problem. I wrote a bash script to get the status of an app. Script is running fine when i am executing it from shell but when I am trying to execute the same script from crontab its not working. Not sure what is happening here...



Both manual and cron are running from root account.



Answer



This is generally because cron does not enable the PATH the same way as the shell does. Try typing "echo $PATH" at a prompt. Take the resulting PATH string and add it to the top of crontab file as PATH= That will probably fix it.



Mark


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...