A while back I faced an issue in which a script set up on cron was not sending mails, and the strange thing was that, when I was running the script from the shell, it was sending mails.
So, it was confirmed that there is no issue with the code or mail command in the script. What was the issue then?
After searching on google, I found out that cron doesn't have all the permissions and privileges which the user has. In my case, though the script in cron was set up by the user who has the privilege to run the mail command, but it wasn't running with the privileges of the user.
Some values were missing from the PATH environment variables due to which the shell was unable to recognize the command name.
How to deal with this problem?
There are many ways to deal with problems like this
1) Execute the profile of the user which has PATH variable set as required.
2) Write command name with full path.
3) Set up PATH environment variable in the script to include the Path of the command.
For more info visit
No comments:
Post a Comment