[CentOS] difference between cron and shell invocation.

2010-12-07 Thread James B. Byrne

I have a fairly involved root cron task that I moved verbatim from
another server. On the original server, this task ran without
problem.  On the new server, when this task runs via cron, which I
confirm is happening by looking in the cron log, no files are
transferred and no error is reported.  However, if I copy cron
command from roots crontab and paste it into a terminal session on
the new server then the task runs to completion and the files are
transferred.

This task involves sshfs, fuse, and rsync and employs pki
certificates for authentication.  The fact that it works from the
shell without alteration and yet not from cron is the issue.

Does anyone have any idea where I would start to track down what is
going on?



-- 
***  E-Mail is NOT a SECURE channel  ***
James B. Byrnemailto:byrn...@harte-lyne.ca
Harte  Lyne Limited  http://www.harte-lyne.ca
9 Brockley Drive  vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada  L8E 3C3

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] difference between cron and shell invocation.

2010-12-07 Thread m . roth
James B. Byrne wrote:

 I have a fairly involved root cron task that I moved verbatim from
 another server. On the original server, this task ran without
 problem.  On the new server, when this task runs via cron, which I
 confirm is happening by looking in the cron log, no files are
 transferred and no error is reported.  However, if I copy cron
 command from roots crontab and paste it into a terminal session on
 the new server then the task runs to completion and the files are
 transferred.

 This task involves sshfs, fuse, and rsync and employs pki
 certificates for authentication.  The fact that it works from the
 shell without alteration and yet not from cron is the issue.

 Does anyone have any idea where I would start to track down what is
 going on?

Sure - it's pretty obvious that something in the environment is missing.
Try putting env in the cron job, or run the actual job as a shell script,
and in the script, put env and pipe that to a file, so that you can then
compare that with your env o/p as root.

  mark

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] difference between cron and shell invocation.

2010-12-07 Thread Tony Molloy
On Tuesday 07 December 2010 14:34:33 James B. Byrne wrote:
 I have a fairly involved root cron task that I moved verbatim from
 another server. On the original server, this task ran without
 problem.  On the new server, when this task runs via cron, which I
 confirm is happening by looking in the cron log, no files are
 transferred and no error is reported.  However, if I copy cron
 command from roots crontab and paste it into a terminal session on
 the new server then the task runs to completion and the files are
 transferred.
 
 This task involves sshfs, fuse, and rsync and employs pki
 certificates for authentication.  The fact that it works from the
 shell without alteration and yet not from cron is the issue.
 
 Does anyone have any idea where I would start to track down what is
 going on?

Check the paths in cron. They are not necessarly the same as the paths for the 
shell.

Tony
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] difference between cron and shell invocation.

2010-12-07 Thread Robert Heller
At Tue, 7 Dec 2010 09:34:33 -0500 (EST) CentOS mailing list centos@centos.org 
wrote:

 
 
 I have a fairly involved root cron task that I moved verbatim from
 another server. On the original server, this task ran without
 problem.  On the new server, when this task runs via cron, which I
 confirm is happening by looking in the cron log, no files are
 transferred and no error is reported.  However, if I copy cron
 command from roots crontab and paste it into a terminal session on
 the new server then the task runs to completion and the files are
 transferred.
 
 This task involves sshfs, fuse, and rsync and employs pki
 certificates for authentication.  The fact that it works from the
 shell without alteration and yet not from cron is the issue.
 
 Does anyone have any idea where I would start to track down what is
 going on?

Things to check:

Environment issues: PATH, SHELL, etc.

I would put in calls to logger and/or echo to log what is going on. 
Adding a '-v' (verbose flag) to selected commands to generate additional
debug information can also help.

Is anything making use of stdin?

Does the script still work if you do something like from an interactive
shell?:

/dev/null ./script

Is anything dependent on having access to an actual console device (eg
/dev/tty)?  That is, are any of the programs trying to be interactive?

What are you doing about stderr's channel?  Does adding '21' to the
command in crontab prove enlightening?

 
 
 

-- 
Robert Heller -- 978-544-6933 / hel...@deepsoft.com
Deepwoods Software-- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


 
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] difference between cron and shell invocation.

2010-12-07 Thread James B. Byrne

On Tue, December 7, 2010 09:49, Brent L. Bates wrote:
  If you aren't already doing so, use the full path to the
 commands you are

I have done as you suggest and that indeed has solved the problem. 
Thank you very much.

Regards,

-- 
***  E-Mail is NOT a SECURE channel  ***
James B. Byrnemailto:byrn...@harte-lyne.ca
Harte  Lyne Limited  http://www.harte-lyne.ca
9 Brockley Drive  vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada  L8E 3C3

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] difference between cron and shell invocation.

2010-12-07 Thread James B. Byrne
Question.  In a chained cron job like this:

sshfs  .  .  .  /usr/bin/rsync .  .  . | /bin/mail -s .  .  .  .
 .  .

Is there anyway to get a failure message from the first part to be
emailed or logged?

Given the resolution of this problem I gather that sshfs must not
have been found and therefore I would expect an error to be reported
somewhere.  The chained commands evidently interfered with the
propagation of this error which would have immediately identified
the source of the problem. Is it possible to get errors from the
individual parts of such chained commands forwarded to an email
address, or logged in the system log, or both?

-- 
***  E-Mail is NOT a SECURE channel  ***
James B. Byrnemailto:byrn...@harte-lyne.ca
Harte  Lyne Limited  http://www.harte-lyne.ca
9 Brockley Drive  vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada  L8E 3C3

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] difference between cron and shell invocation.

2010-12-07 Thread Robert Heller
At Tue, 7 Dec 2010 10:21:27 -0500 (EST) CentOS mailing list centos@centos.org 
wrote:

 
 Question.  In a chained cron job like this:
 
 sshfs  .  .  .  /usr/bin/rsync .  .  . | /bin/mail -s .  .  .  .
  .  .
 
 Is there anyway to get a failure message from the first part to be
 emailed or logged?
 
 Given the resolution of this problem I gather that sshfs must not
 have been found and therefore I would expect an error to be reported
 somewhere.  The chained commands evidently interfered with the
 propagation of this error which would have immediately identified
 the source of the problem. Is it possible to get errors from the
 individual parts of such chained commands forwarded to an email
 address, or logged in the system log, or both?

It is probably easiest to create a shell script with all of the chaining
there and use shell script flow control to deal with mailing/logging
errors:

#!/bin/sh -e
sshfs  .  .  . 
/usr/bin/rsync .  .  . 21 | /bin/mail -s .  .  . 
..

Or something like that (eg using '|| error-handling/reporting code'
instead of -e).

 

-- 
Robert Heller -- 978-544-6933 / hel...@deepsoft.com
Deepwoods Software-- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


 
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] difference between cron and shell invocation.

2010-12-07 Thread m . roth
James B. Byrne wrote:
 Question.  In a chained cron job like this:

 sshfs  .  .  .  /usr/bin/rsync .  .  . | /bin/mail -s .  .  .  .
  .  .

 Is there anyway to get a failure message from the first part to be
 emailed or logged?

 Given the resolution of this problem I gather that sshfs must not
 have been found and therefore I would expect an error to be reported
 somewhere.  The chained commands evidently interfered with the
 propagation of this error which would have immediately identified
 the source of the problem. Is it possible to get errors from the
 individual parts of such chained commands forwarded to an email
 address, or logged in the system log, or both?

If you're going to get that complicated, why not just write a short shell
script, and run that via cron. Then you can set your environment
explicitly (as opposed to in your crontab, which some folks like to do).
Also, if you want logs from each piece, you could then break it up, and
dump/read stuff from temp files.

 mark

___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] difference between cron and shell invocation.

2010-12-07 Thread Les Mikesell
On 12/7/10 9:21 AM, James B. Byrne wrote:
 Question.  In a chained cron job like this:

 sshfs  .  .  .  /usr/bin/rsync .  .  . | /bin/mail -s .  .  .  .
   .  .

 Is there anyway to get a failure message from the first part to be
 emailed or logged?

 Given the resolution of this problem I gather that sshfs must not
 have been found and therefore I would expect an error to be reported
 somewhere.  The chained commands evidently interfered with the
 propagation of this error which would have immediately identified
 the source of the problem. Is it possible to get errors from the
 individual parts of such chained commands forwarded to an email
 address, or logged in the system log, or both?


Cron should default to mailing anything sent to stdout or stderr to the owner 
of 
the job if you don't redirect it elsewhere.

-- 
   Les Mikesell
lesmikes...@gmail.com
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos