Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a baffling issue with a simple script I wrote that, when run, will send an E-mail with my current ip address.
I have configured crontab to execute the script which runs but does not end up sending the e-mail.
If I run the same script manually (./script) the e-mail gets sent.
I write to a log each time the script runs so I know that cron is executing the script.
Any tips what might cause this is greatly appreciated.
Last edited by twallstrom; 06-07-2015 at 01:55 AM.
If you search LQ for this then usually it's down to using full paths and such. If you want to troubleshoot the cause yourself then make your cron job be a BASH script (see first line of script) then make the second line read "set -vx" (w/o the double quotes), have cron execute it, then check root (or rather the unprivileged users mail account that receives root) email for clues, elif post your script in full (and preferably between vBB code tags).
It was a PATH issue. When I provided the full path to the command (ssmtp) it worked like a charm.
Still I do not understand why the it worked when I was logged in via SSH and ran the command manually (./script) but not with Cron? I assume cron is not run as my user even though it was configured with that same user.
I think that was already explained, cron has its own environment and that is restricted, so it won't find those commands for you (but you need to specify them using full path).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.