[opensuse] crontab problem? How to debug?
we are having odd problem with running PHP scripts from cron, we are able to execute the same commands from shell under "clotho04" user, but crontab for the same user sends us following email:
From clotho04@rpcweb.ourdomain.com Fri Sep 14 06:30:01 2007 X-Original-To: clotho04 Delivered-To: clotho04@rpcweb.ourdomain.com From: root@rpcweb.ourdomain.com (Cron Daemon) To: clotho04@rpcweb.ourdomain.com Subject: Cron
$PHP_BIN_PATH $EXPORT_TOOLS/order_export.php X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: Date: Fri, 14 Sep 2007 06:30:01 -0500 (CDT)
Could not open input file: /home/httpd/htdocs/devestore.ourdomain.com/website/export/order_export.php This is on SLES9 What might cause such a set of results .... it was fine until recently. Peter -- Everything is vague to a degree you do not realize till you have tried to make it precise. Bertrand Russell www.the-brights.net -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Friday 2007-09-14 at 07:10 -0500, Peter Van Lone wrote:
X-Cron-Env:
Try setting that one. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFG6nydtTMYHG2NR9URAkZ+AJ9D8cjUCxXFqfH6UwG8w3gVF7u4mgCgi9Pq k8eC/BGWC6Q9uop6hXVCXoA= =dkoa -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 9/14/07, Carlos E. R.
X-Cron-Env:
Try setting that one.
Are you saying that the path listed is incorrect? What should it be set to? And ... any idea how it might have changed from just a day or two ago, when none of the users have modified env settings (or so they say). One of the website devs thinks it has to do with a "general permissions issue" -- whatever that means. How could I verify or reject that hypothesis? finally -- and forgive my ignorance -- but what tool, as root, do I use to fix this users X-Cron-Env: variable, if that is, indeed, the problem? Peter -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Friday 2007-09-14 at 08:36 -0500, Peter Van Lone wrote:
X-Cron-Env:
Try setting that one.
Are you saying that the path listed is incorrect? What should it be set to?
Not incorrect, different. The path, and other environment variables, that
programs running as cron jobs get are different that what they get when
running normally. Whether this is a problem or not depends on each
particular script, program, whatever. That's why some usually declare
their own path inside the script.
It might be what is happening here, or maybe not. It is just a typical
problem, thus my suggestion.
There is another possibility:
X-Cron-Env:
And ... any idea how it might have changed from just a day or two ago, when none of the users have modified env settings (or so they say).
Nop. No idea. It could be a small modification in the script.
One of the website devs thinks it has to do with a "general permissions issue" -- whatever that means. How could I verify or reject that hypothesis?
No idea... Usually, you look at logs and output. There is no general easy method to know which file can't be opened, unless the programs says so clearly. Perhaps you can do a "trace" of the program. ¿Can that file, '/home/httpd/htdocs/devestore.ourdomain.com/website/export/order_export.php' be opened? Check all dirs in the path. I would perhaps write debugging strings to the console or a log file from the script so that you can check what the program is really doing. Old style ;-)
finally -- and forgive my ignorance -- but what tool, as root, do I use to fix this users X-Cron-Env: variable, if that is, indeed, the problem?
The script should define the needed environment vars, or define them in the line calling the script. man cron may suggest other possibilities. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFG6photTMYHG2NR9URAumlAKCGGP1c2J6/XYGCHN3WMVfSpKoh4ACgmNKr fXCZ+EH1cEDZU/daP5V/1oU= =4QYa -----END PGP SIGNATURE-----
On 9/14/07, Carlos E. R.
Not incorrect, different. The path, and other environment variables, that programs running as cron jobs get are different that what they get when running normally. Whether this is a problem or not depends on each particular script, program, whatever. That's why some usually declare their own path inside the script.
well since the exact same script works from shell (logged in as same user) but not from crontab ... then that would seem to suggest somthing about the crontab env specifically, correct? Where would I look to find what env variables are being set in crontab -- or to compare those to what is set for this user in the shell?
Usually, you look at logs and output. There is no general easy method to know which file can't be opened, unless the programs says so clearly. Perhaps you can do a "trace" of the program.
¿Can that file, '/home/httpd/htdocs/devestore.ourdomain.com/website/export/order_export.php' be opened? Check all dirs in the path.
I think that the script is reporting that the file cannot be opened ... but from shell is fine.
I would perhaps write debugging strings to the console or a log file from the script so that you can check what the program is really doing. Old style ;-)
I will suggest that ... good idea Wish I knew more about debugging this kind of thing ... I'll go dig around some, but will probably end up posting back with more questions! Peter -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Peter Van Lone wrote:
well since the exact same script works from shell (logged in as same user) but not from crontab ... then that would seem to suggest somthing about the crontab env specifically, correct?
Or it isn't the exact same script or exact same user :)
Where would I look to find what env variables are being set in crontab -- or to compare those to what is set for this user in the shell?
Add the following commands to your crontab entry (or the script itself) who am i whoami groups ls -l /home/httpd/htdocs/devestore.ourdomain.com/website/export/order_export.ph Also see what happens when you run them in the shell. Make sure there are no differences. Cheers, Dave -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Friday 2007-09-14 at 09:29 -0500, Peter Van Lone wrote:
well since the exact same script works from shell (logged in as same user) but not from crontab ... then that would seem to suggest somthing about the crontab env specifically, correct?
That's what I thought, yes.
Where would I look to find what env variables are being set in crontab -- or to compare those to what is set for this user in the shell?
Precisely the error email from cron tells you them. The manual page from cron and crontab should explain about it. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFG6sWTtTMYHG2NR9URAtcuAJ4uIhIXlfpRlk8zbsX3Ksvk9RXpDwCgkUPN t9KOUhMkwZJYGTCEVIZvavk= =wkc3 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Quoting Peter Van Lone
On 9/14/07, Carlos E. R.
wrote: Not incorrect, different. The path, and other environment variables, that programs running as cron jobs get are different that what they get when running normally. Whether this is a problem or not depends on each particular script, program, whatever. That's why some usually declare their own path inside the script.
well since the exact same script works from shell (logged in as same user) but not from crontab ... then that would seem to suggest somthing about the crontab env specifically, correct?
Cron runs programs directly, not thru the shell. IIRC, if you use file globbing or other shell specific special characters, cron will call the shell to call the program. Or you can explicitly invoke the shell, e.g.: /bin/sh -c "/home/user/cronjob arg1" HTH, Jeff -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Fri, 2007-09-14 at 19:14 -0500, Jeffrey L. Taylor wrote:
Quoting Peter Van Lone
: On 9/14/07, Carlos E. R.
wrote: Not incorrect, different. The path, and other environment variables, that programs running as cron jobs get are different that what they get when running normally. Whether this is a problem or not depends on each particular script, program, whatever. That's why some usually declare their own path inside the script.
well since the exact same script works from shell (logged in as same user) but not from crontab ... then that would seem to suggest somthing about the crontab env specifically, correct?
Cron runs programs directly, not thru the shell.
Ah, yes it does it uses a non-interactive shell. IIRC it uses bash by default but you can specify the shell used with the hash bang directive on the first line: #!/bin/<shell of your choice> And then specify other shell env settings to your liking. -- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (5)
-
Carlos E. R.
-
Dave Howorth
-
Jeffrey L. Taylor
-
Kenneth Schneider
-
Peter Van Lone