LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 08: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, 08:51 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,625

Rep: Reputation: 5120Reputation: 5120Reputation: 5120Reputation: 5120Reputation: 5120Reputation: 5120Reputation: 5120Reputation: 5120Reputation: 5120Reputation: 5120Reputation: 5120
use double & instead of single one:
git clone ... && another command
but I still do not understand that | before while
 
Old 05-25-2016, 10: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, 12:18 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,575

Rep: Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:42 PM
[SOLVED] bash wait for one line to finish before going to the next line Mike_V Programming 6 01-10-2011 07:20 PM
inconsistency issue of git-clone ***/git/mesa/drm with the existing kernel source centguy Linux - Desktop 2 10-08-2008 11:36 PM
How to create a bash script to wait for wget to finish and then continue danlee Linux - General 14 05-30-2008 12:21 PM
bash-script won't wait for application to finish TLV Linux - Software 24 10-01-2004 12:18 AM

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

All times are GMT -5. The time now is 12:13 PM.

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