LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-25-2016, 07:27 AM   #1
luftwaffe
LQ Newbie
 
Registered: Jul 2002
Posts: 19

Rep: Reputation: 0
Wait for “git clone” to finish in bash


I have a sequential script in which there is a git clone. I would like to make sure that the actual git process is finished before executing the next step. I tried

Code:
git clone https://github.example.com/Sample/Example.git & export PID=${!} | while [[ ( -d /proc/$PID ) && ( -z `grep zombie /proc/$PID/status` ) ]]; do sleep 1; done
and various other ways but could not manage how to wait until the actual git clone is done. Any hint on this one please?
 
Old 05-25-2016, 07:51 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,918

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
use double & instead of single one:
git clone ... && another command
but I still do not understand that | before while
 
Old 05-25-2016, 09:43 AM   #3
luftwaffe
LQ Newbie
 
Registered: Jul 2002
Posts: 19

Original Poster
Rep: Reputation: 0
There is a shell script what invokes "git clone" to replicate a source tree on which some operations are done. The problem is that git clone runs async spawning a number of "git-remote-https" jobs to download the repo content and then it returns immediately.
The question is how I can check when a particular git clone is fully completed when run by cron and know that the repo is complete while other git commands may run with the same name.
Is there any way to force git to be synchronous?
 
Old 05-25-2016, 11:18 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
maybe:
Code:
git clone https://github.example.com/Sample/Example.git &
PID=$!
wait $PID
Which is of course identical to just
Code:
git clone https://github.example.com/Sample/Example.git
because git runs synchronously by default...
 
  


Reply

Tags
bash, git



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: A Redis-based microservice in bash for automating git clone and npm install LXer Syndicated Linux News 0 04-03-2016 03:42 PM
[SOLVED] bash wait for one line to finish before going to the next line Mike_V Programming 6 01-10-2011 06:20 PM
inconsistency issue of git-clone ***/git/mesa/drm with the existing kernel source centguy Linux - Desktop 2 10-08-2008 10:36 PM
How to create a bash script to wait for wget to finish and then continue danlee Linux - General 14 05-30-2008 11:21 AM
bash-script won't wait for application to finish TLV Linux - Software 24 09-30-2004 11:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration