{"thread":{"id":"24221","subject":"[OT?] Executing Git from bash script invoked by cron","startedAt":"2010-06-28T21:00:56Z","lastAt":"2010-07-03T17:19:51Z","messageCount":7,"participants":["Johannes Schneider","Sverre Rabbelier","Marc Weber","Ramkumar Ramachandra","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144416","messageId":"4C290D88.80306@cedarsoft.com","threadId":"24221","inReplyTo":null,"subject":"[OT?] Executing Git from bash script invoked by cron","fromName":"Johannes Schneider","fromEmail":"mailings@cedarsoft.com","sentAt":"2010-06-28T21:00:56Z","receivedAt":"2010-06-28T21:00:56Z","isPatch":false,"sender":{"key":"mailings@cedarsoft.com","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nHi,\n\nI try to mirror my local git repository.\nTherefore I created a bash script. This script, executed form the\ncommand line, works fine.\n\nBut the same script executed by cron, does not work. Git push does\nsimply nothing. No output, no push, nothing.\nBut git log and git --version works...\n\nI tried to google the problem, but couldn't not find anything useful.\nAny hints are welcome.\n\n\nUbuntu 64Bit\ngit version 1.7.0.4\ncron 3.0pl1-106ubuntu5\n\n\nThanks,\n\nJohannes\n- -- \nJohannes Schneider - blog.cedarsoft.com\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\niQEcBAEBAgAGBQJMKQ2GAAoJEAytD9R7Qv6dRmIH/3YqxEMRDLeHcLfsH0JYBdOT\nNG2e7mMjiYg2akQOsXSN4iN1iMrRfj/gp9udd7QM4p8W06xlv0wftOC87IKZKDtp\nDujAYB6hHMtHYkVrWV9KuP+ptuaZDvhgti+8DvfAKGuXbRa0xs4CcRCclLLNrj6x\ntqJJZatdVZgvEDBePWVcTJfglJf+2lozxBXvTkat8mjEGCYDuUfvG37yimSETZHT\nwJITWGi3BdMG5m6xHOHDYp4IHuGw2sfWYAN3EE7dS6m2P7/l/VRM18PsAWFM3j1Q\nAxv57mkJu1ea9tj54W7I7kJCHDC5TZDf9FXSPPOMY1t1qzgtGfB7tfQMDamHIYY=\n=LRSS\n-----END PGP SIGNATURE-----\n"},{"id":"144417","messageId":"AANLkTimHw_UcpiJdiVaz8pyYH6jhHa_x2DS1vTNlreau@mail.gmail.com","threadId":"24221","inReplyTo":"4C290D88.80306@cedarsoft.com","subject":"Re: [OT?] Executing Git from bash script invoked by cron","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-06-28T21:05:20Z","receivedAt":"2010-06-28T21:05:20Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Mon, Jun 28, 2010 at 23:00, Johannes Schneider\n<mailings@cedarsoft.com> wrote:\n> But the same script executed by cron, does not work. Git push does\n> simply nothing. No output, no push, nothing.\n\nVery silly question, does the cron version have anything to push? IIRC\n'git push' doesn't output anything if there's nothing to push? Try\nrunning 'git push --verbose' instead.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"144418","messageId":"1277759597-sup-9397@nixos","threadId":"24221","inReplyTo":"4C290D88.80306@cedarsoft.com","subject":"Re: [OT?] Executing Git from bash script invoked by cron","fromName":"Marc Weber","fromEmail":"marco-oweber@gmx.de","sentAt":"2010-06-28T21:17:17Z","receivedAt":"2010-06-28T21:17:17Z","isPatch":false,"sender":{"key":"marco-oweber@gmx.de","avatar":null},"body":"Excerpts from Johannes Schneider's message of Mon Jun 28 23:00:56 +0200 2010:\n> Hash: SHA1\n> \n> Hi,\n> \n> I try to mirror my local git repository.\n> Therefore I created a bash script. This script, executed form the\n> command line, works fine.\n> \n> But the same script executed by cron, does not work. Git push does\n> simply nothing. No output, no push, nothing.\n> But git log and git --version works...\n> \n> I tried to google the problem, but couldn't not find anything useful.\n> Any hints are welcome.\n\nWhat do you do in such cases? Make sure you log both: stdout and stderr.\n\na)\nsh -c 'your quoted command &> /tmp/logfile'\n\nb) if this still does not work use strace:\n\nsh -c 'strace -f-o /tmp/strace.log your quoted command &> /tmp/logfile'\n\nThen you know how much is happening.\n\nYou may also want to check that the environment is the same. Eg\nexport > file to create a file containing your environment.\nThen source it in the cron job line somehow.\n\nI'm not using cron that often so the solution could be simpler.\n\nMarc Weber\n"},{"id":"144419","messageId":"AANLkTim0fmxUJERuGP0hBhfD5ZtyKvo34PGQKJg0pCrT@mail.gmail.com","threadId":"24221","inReplyTo":"1277759597-sup-9397@nixos","subject":"Re: [OT?] Executing Git from bash script invoked by cron","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-06-28T21:22:09Z","receivedAt":"2010-06-28T21:22:09Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\n[Mark, please don't cull the cc list]\n\nOn Mon, Jun 28, 2010 at 23:17, Marc Weber <marco-oweber@gmx.de> wrote:\n> b) if this still does not work use strace:\n>\n> sh -c 'strace -f-o /tmp/strace.log your quoted command &> /tmp/logfile'\n\nIf you have to result to strace with git, it will probably then be\nhelpful to use GIT_TRACE=1, it will at least tell you what commands\nare being invoked by git in a semi-human-readable format.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"144420","messageId":"20100628214324.GB30558@debian","threadId":"24221","inReplyTo":"4C290D88.80306@cedarsoft.com","subject":"Re: [OT?] Executing Git from bash script invoked by cron","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-06-28T21:43:24Z","receivedAt":"2010-06-28T21:43:24Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Johannes,\n\nJohannes Schneider writes:\n> I try to mirror my local git repository.\n> Therefore I created a bash script. This script, executed form the\n> command line, works fine.\n> \n> But the same script executed by cron, does not work. Git push does\n> simply nothing. No output, no push, nothing.\n> But git log and git --version works...\n\nPerhaps you're not executing that `git push` as the same user, and\ntherefore there's some problem reading the config files to determine\nwhere to push to? I really can't tell much else without some output.\n\n-- Ram\n"},{"id":"144442","messageId":"vpqhbkm9x01.fsf@bauges.imag.fr","threadId":"24221","inReplyTo":"4C290D88.80306@cedarsoft.com","subject":"Re: [OT?] Executing Git from bash script invoked by cron","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-06-29T06:24:46Z","receivedAt":"2010-06-29T06:24:46Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Johannes Schneider <mailings@cedarsoft.com> writes:\n\n> But the same script executed by cron, does not work. Git push does\n> simply nothing. No output, no push, nothing.\n> But git log and git --version works...\n\nOne common problem with cron jobs is that you don't have the same\n$PATH in your shell and in cron. If you have no output at all, I'd say\nyou didn't reach the line where git is executed in your script.\n\nTry to add a\n\n  set -x\n\nat the beginning of your script to see what it's doing.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"144749","messageId":"4C2F7137.6020209@cedarsoft.com","threadId":"24221","inReplyTo":"1277759597-sup-9397@nixos","subject":"Re: [OT?] Executing Git from bash script invoked by cron","fromName":"Johannes Schneider","fromEmail":"mailings@cedarsoft.com","sentAt":"2010-07-03T17:19:51Z","receivedAt":"2010-07-03T17:19:51Z","isPatch":false,"sender":{"key":"mailings@cedarsoft.com","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nOn 06/28/2010 11:17 PM, Marc Weber wrote:\n> sh -c 'your quoted command &> /tmp/logfile'\n> \n> b) if this still does not work use strace:\n\nThat is it. Thanks.\nOf course, git writes to stderr. And I did not redirect it properly.\nI don't understand the details, but this line is working now:\n\nsh -c 'myscript' >> logfile 2> err\n\n\nThe problem - by the way - is related to ssh authentification...\nBut that is another issue...\n\n\nBut here comes my question: Obviously all output created by git push is\nwritten to stderr. I'd expected that most of the content will end up in\nstdout.\nBut I am sure there is a good reason for it - so I just accept it ;-)\n\n\nThanks,\n\nJohannes\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\niQEcBAEBAgAGBQJML3E0AAoJEAytD9R7Qv6dZ5cIANpYYu5isncB3LcLaQgURQmP\nesxkrtAVrcghItv+KkSts+qb8IBlEmA1mkzMYpmgVn6M/CQxh3atlaDsTbNtznAA\neZVJwXqQwoPlJS8ZvoDcSdldcL5Nmi+nyJgg408y5j3GB4AEt8IihxYVW7Xs0pFQ\nGdBOSjV/TK1PEjcP7dNYJ9MSdUFA6Z7GrywRKQwlRZ4C611wCBpEoAeD0S1vcJcl\nB78DTIqB+P3VF+mLW3u2LRXUdp3+tM2uutGR7DkG6GVomHJkwb5zAGXU4AmwHt2L\nOdDwPAAZ5OzAgfyqLZ4YrOMv9Pg8sOjj+YLfljLUIXB/muJPACqNljv+liCmrac=\n=X2Lj\n-----END PGP SIGNATURE-----\n"}]}