Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: BASH question: command works when called manually but not when called by a program

  1. #11
    Join Date
    Dec 2006
    Beans
    256

    Re: BASH question: command works when called manually but not when called by a progra

    Quote Originally Posted by daqron View Post
    So I reconfigured it again. Still makes no sense.

    - Running the command directly works (root or not)
    - Running the command via a script from terminal works (root or not)
    - Having cron run the script does not work
    - Having heyu run the script does not work

    Doesn't cron run as root?
    Each user has his own cron table. The command will run as the user who added the job (to his crontab).

    How can root run a script and get a different result than cron!? All commands and file locations use explicit paths.
    Though the user may be the same, the environment may be different. (There can even be some differences in the environment depending upon whether the user is running under sudo, and on how sudo has been configured.)

    Now that all of your paths are explicit, this is not likely to be a problem (assuming that the user who create cron job has the necessary permissions to any files or directories). If there is an environment problem, you should examine whether your 'heyu' program depends on or uses any environment settings.

    I am not that familiar with the cron implementation used by Ubuntu (Vixie?). I use Dillon's cron which is a bit more straightforward. Under Dillon's cron any output to stdout or stderr produced by the job gets collected and mailed to the user.

    I would not expect a re-direction to a log file to be included in, or interfere with, such a mailing but it might be worthwhile for you to investigate this for your cron implementation (it may even be a problem with my cron implementation, but I have never tried implementing logging in that manner). Your system's cron implementation may even provide some explicit logging mechanism.

    Also, you might also double-check whether the output produced by 'heyu' is to stdout and not stderr; or combine both pipes ("2>&1") before appending them to the log file.
    "We visited sixty-six islands and landed eighty-one times, wading, swimming (to shore). Most of the people were friendly and delightful; only two arrows shot at us, and only one went near -- So much for savages!" - J.C. Patterson

  2. #12
    Join Date
    Sep 2007
    Location
    Seattle, USA
    Beans
    116
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: BASH question: command works when called manually but not when called by a progra

    Quote Originally Posted by saulgoode View Post
    Also, you might also double-check whether the output produced by 'heyu' is to stdout and not stderr; or combine both pipes ("2>&1") before appending them to the log file.
    Thanks for the explanation on cron. What you articulated about its behavior is what I assumed to be the case. I think your last note was the key. I already had the script piping stdout and stderr into an output string that is reported to the log. For whatever reason, that directive is what didn't work in cron (even though it worked when I ran the script manually).

    So it's working now. It seems that I was dealing with two separate problems. With the original shell script I posted, I still don't know what the problem was. I researched the heyu engine some more and it is fully capable of multiple parallel operations, so my hypothesis about it being too busy was probably wrong. After re-writing in perl and testing with cron, the problem seems to have been trying to capture stderr and stdout.

    Of course, these explanations could still be completely wrong, but it's working now so I'm calling it solved.

    Thanks again to everyone who provided input. I really appreciate your time.

    Cheers,
    Jeremy
    "I take it from your glum demeanor that your ill-advised foray into time-travel destroyed yet another reality."

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •