Subject: Re: [OT?] Executing Git from bash script invoked by cron

From: Marc Weber <[email-masked]>
Date: Mon, 28 Jun 2010 23:17:17 +0200

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