Re: BASH question: command works when called manually but not when called by a progra
Originally Posted by
daqron
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
Bookmarks