LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   odd (or not) problem with root (https://www.linuxquestions.org/questions/linux-server-73/odd-or-not-problem-with-root-938294/)

DirtyHowi 04-05-2012 09:30 AM

odd (or not) problem with root
 
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.

tia

druuna 04-05-2012 09:41 AM

Hi,

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?

Hope this helps.

T3RM1NVT0R 04-05-2012 09:43 AM

Hi DirtyHowi,

That depends on how you have put that in cron. If it works from the command line then it appearss to me as @ symbol is creating problem.

Did you try putting that command in a file and running that file as a script via cron?

DirtyHowi 04-05-2012 09:47 AM

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.

catkin 04-05-2012 12:01 PM

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 ...


All times are GMT -5. The time now is 01:34 AM.