Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
RHEL 6.1, when we send an email from our cobol system it goes out from root, which we have aliased in our postfix file and another custom file as (company) orderdesk@company.com. this works fine everything flows like it should.
we also have a cron job that runs every few minutes (15 i think) and goes and pulls text files out of a directory and attaches them to email and sends them as root@servername.company.local.
i can manually run the program that the cron job runs, even logged in as root and it runs fine, but fails to run when done via cron.
anyone seen this before? i'm having a tough time understanding why when manually executed it works perfectly, but when automatically executed it fails. same code both times.
I've seen symptoms you describe. There isn't a global solution, it could be the crontab entry, missing variables in your crontab, the script could use environment settings that aren't present when run from cron, etc.
Did you check the log files? Anything stand out?
If that doesn't help: Can you post the script and the full crontab entry?
its a cobol program that gets called, not just a script, so if i runcbl PROGNAME it runs fine. run from cron it doesnt. it makes it to our email appliance and then stops there, so it is getting out, just not out of the building. when run manually it picks up the root email from postfix, run from cron it doesn't.
It's probably something to do with the difference in the shell/process environment between running under cron and running from the command prompt. Assuming the shell logon scripts don't prompt the user for input you could test that theory by running the cron job as root with an su - (the - is important) to the normal user.
If the email goes out then, at least you know the problem area to look in. A likely area is environment variables but it could be others -- current directory, umask, limits ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.