git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [OT?] Executing Git from bash script invoked by cron
@ 2010-06-28 21:00 Johannes Schneider
  2010-06-28 21:05 ` Sverre Rabbelier
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Johannes Schneider @ 2010-06-28 21:00 UTC (permalink / raw)
  To: git

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I try to mirror my local git repository.
Therefore I created a bash script. This script, executed form the
command line, works fine.

But the same script executed by cron, does not work. Git push does
simply nothing. No output, no push, nothing.
But git log and git --version works...

I tried to google the problem, but couldn't not find anything useful.
Any hints are welcome.


Ubuntu 64Bit
git version 1.7.0.4
cron 3.0pl1-106ubuntu5


Thanks,

Johannes
- -- 
Johannes Schneider - blog.cedarsoft.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBAgAGBQJMKQ2GAAoJEAytD9R7Qv6dRmIH/3YqxEMRDLeHcLfsH0JYBdOT
NG2e7mMjiYg2akQOsXSN4iN1iMrRfj/gp9udd7QM4p8W06xlv0wftOC87IKZKDtp
DujAYB6hHMtHYkVrWV9KuP+ptuaZDvhgti+8DvfAKGuXbRa0xs4CcRCclLLNrj6x
tqJJZatdVZgvEDBePWVcTJfglJf+2lozxBXvTkat8mjEGCYDuUfvG37yimSETZHT
wJITWGi3BdMG5m6xHOHDYp4IHuGw2sfWYAN3EE7dS6m2P7/l/VRM18PsAWFM3j1Q
Axv57mkJu1ea9tj54W7I7kJCHDC5TZDf9FXSPPOMY1t1qzgtGfB7tfQMDamHIYY=
=LRSS
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OT?] Executing Git from bash script invoked by cron
  2010-06-28 21:00 [OT?] Executing Git from bash script invoked by cron Johannes Schneider
@ 2010-06-28 21:05 ` Sverre Rabbelier
  2010-06-28 21:17 ` Marc Weber
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Sverre Rabbelier @ 2010-06-28 21:05 UTC (permalink / raw)
  To: Johannes Schneider; +Cc: git

Heya,

On Mon, Jun 28, 2010 at 23:00, Johannes Schneider
<mailings@cedarsoft.com> wrote:
> But the same script executed by cron, does not work. Git push does
> simply nothing. No output, no push, nothing.

Very silly question, does the cron version have anything to push? IIRC
'git push' doesn't output anything if there's nothing to push? Try
running 'git push --verbose' instead.

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OT?] Executing Git from bash script invoked by cron
  2010-06-28 21:00 [OT?] Executing Git from bash script invoked by cron Johannes Schneider
  2010-06-28 21:05 ` Sverre Rabbelier
@ 2010-06-28 21:17 ` Marc Weber
  2010-06-28 21:22   ` Sverre Rabbelier
  2010-07-03 17:19   ` Johannes Schneider
  2010-06-28 21:43 ` Ramkumar Ramachandra
  2010-06-29  6:24 ` Matthieu Moy
  3 siblings, 2 replies; 7+ messages in thread
From: Marc Weber @ 2010-06-28 21:17 UTC (permalink / raw)
  To: git

Excerpts from Johannes Schneider's message of Mon Jun 28 23:00:56 +0200 2010:
> Hash: SHA1
> 
> Hi,
> 
> I try to mirror my local git repository.
> Therefore I created a bash script. This script, executed form the
> command line, works fine.
> 
> But the same script executed by cron, does not work. Git push does
> simply nothing. No output, no push, nothing.
> But git log and git --version works...
> 
> I tried to google the problem, but couldn't not find anything useful.
> Any hints are welcome.

What do you do in such cases? Make sure you log both: stdout and stderr.

a)
sh -c 'your quoted command &> /tmp/logfile'

b) if this still does not work use strace:

sh -c 'strace -f-o /tmp/strace.log your quoted command &> /tmp/logfile'

Then you know how much is happening.

You may also want to check that the environment is the same. Eg
export > file to create a file containing your environment.
Then source it in the cron job line somehow.

I'm not using cron that often so the solution could be simpler.

Marc Weber

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OT?] Executing Git from bash script invoked by cron
  2010-06-28 21:17 ` Marc Weber
@ 2010-06-28 21:22   ` Sverre Rabbelier
  2010-07-03 17:19   ` Johannes Schneider
  1 sibling, 0 replies; 7+ messages in thread
From: Sverre Rabbelier @ 2010-06-28 21:22 UTC (permalink / raw)
  To: Marc Weber; +Cc: git, Johannes Schneider

Heya,

[Mark, please don't cull the cc list]

On Mon, Jun 28, 2010 at 23:17, Marc Weber <marco-oweber@gmx.de> wrote:
> b) if this still does not work use strace:
>
> sh -c 'strace -f-o /tmp/strace.log your quoted command &> /tmp/logfile'

If you have to result to strace with git, it will probably then be
helpful to use GIT_TRACE=1, it will at least tell you what commands
are being invoked by git in a semi-human-readable format.

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OT?] Executing Git from bash script invoked by cron
  2010-06-28 21:00 [OT?] Executing Git from bash script invoked by cron Johannes Schneider
  2010-06-28 21:05 ` Sverre Rabbelier
  2010-06-28 21:17 ` Marc Weber
@ 2010-06-28 21:43 ` Ramkumar Ramachandra
  2010-06-29  6:24 ` Matthieu Moy
  3 siblings, 0 replies; 7+ messages in thread
From: Ramkumar Ramachandra @ 2010-06-28 21:43 UTC (permalink / raw)
  To: Johannes Schneider; +Cc: git

Hi Johannes,

Johannes Schneider writes:
> I try to mirror my local git repository.
> Therefore I created a bash script. This script, executed form the
> command line, works fine.
> 
> But the same script executed by cron, does not work. Git push does
> simply nothing. No output, no push, nothing.
> But git log and git --version works...

Perhaps you're not executing that `git push` as the same user, and
therefore there's some problem reading the config files to determine
where to push to? I really can't tell much else without some output.

-- Ram

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OT?] Executing Git from bash script invoked by cron
  2010-06-28 21:00 [OT?] Executing Git from bash script invoked by cron Johannes Schneider
                   ` (2 preceding siblings ...)
  2010-06-28 21:43 ` Ramkumar Ramachandra
@ 2010-06-29  6:24 ` Matthieu Moy
  3 siblings, 0 replies; 7+ messages in thread
From: Matthieu Moy @ 2010-06-29  6:24 UTC (permalink / raw)
  To: Johannes Schneider; +Cc: git

Johannes Schneider <mailings@cedarsoft.com> writes:

> But the same script executed by cron, does not work. Git push does
> simply nothing. No output, no push, nothing.
> But git log and git --version works...

One common problem with cron jobs is that you don't have the same
$PATH in your shell and in cron. If you have no output at all, I'd say
you didn't reach the line where git is executed in your script.

Try to add a

  set -x

at the beginning of your script to see what it's doing.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OT?] Executing Git from bash script invoked by cron
  2010-06-28 21:17 ` Marc Weber
  2010-06-28 21:22   ` Sverre Rabbelier
@ 2010-07-03 17:19   ` Johannes Schneider
  1 sibling, 0 replies; 7+ messages in thread
From: Johannes Schneider @ 2010-07-03 17:19 UTC (permalink / raw)
  To: git

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/28/2010 11:17 PM, Marc Weber wrote:
> sh -c 'your quoted command &> /tmp/logfile'
> 
> b) if this still does not work use strace:

That is it. Thanks.
Of course, git writes to stderr. And I did not redirect it properly.
I don't understand the details, but this line is working now:

sh -c 'myscript' >> logfile 2> err


The problem - by the way - is related to ssh authentification...
But that is another issue...


But here comes my question: Obviously all output created by git push is
written to stderr. I'd expected that most of the content will end up in
stdout.
But I am sure there is a good reason for it - so I just accept it ;-)


Thanks,

Johannes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBAgAGBQJML3E0AAoJEAytD9R7Qv6dZ5cIANpYYu5isncB3LcLaQgURQmP
esxkrtAVrcghItv+KkSts+qb8IBlEmA1mkzMYpmgVn6M/CQxh3atlaDsTbNtznAA
eZVJwXqQwoPlJS8ZvoDcSdldcL5Nmi+nyJgg408y5j3GB4AEt8IihxYVW7Xs0pFQ
GdBOSjV/TK1PEjcP7dNYJ9MSdUFA6Z7GrywRKQwlRZ4C611wCBpEoAeD0S1vcJcl
B78DTIqB+P3VF+mLW3u2LRXUdp3+tM2uutGR7DkG6GVomHJkwb5zAGXU4AmwHt2L
OdDwPAAZ5OzAgfyqLZ4YrOMv9Pg8sOjj+YLfljLUIXB/muJPACqNljv+liCmrac=
=X2Lj
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-03 17:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-28 21:00 [OT?] Executing Git from bash script invoked by cron Johannes Schneider
2010-06-28 21:05 ` Sverre Rabbelier
2010-06-28 21:17 ` Marc Weber
2010-06-28 21:22   ` Sverre Rabbelier
2010-07-03 17:19   ` Johannes Schneider
2010-06-28 21:43 ` Ramkumar Ramachandra
2010-06-29  6:24 ` Matthieu Moy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).