# tar command loop during execution

**URL:** <https://community.unix.com/t/tar-command-loop-during-execution/243795>\
**Category:** UNIX for Advanced & Expert Users\
**Created:** [July 2, 2009, 4:31am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795 "2009-07-02T04:31:25Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jocker](https://community.unix.com/letter_avatar/jocker/32/6_449c533f586939b6e5f246632a46421f.png) [@Jocker](https://community.unix.com/u/Jocker)\
**Post date:** [July 2, 2009, 4:31am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/1 "2009-07-02T04:31:25Z")

</div>

I've some problem concerning tar command.  
Sometime tar command submitted to create a tar file, in execution loop over the same group of files.

Can anyone help me?

Tanks

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [July 2, 2009, 4:41am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/2 "2009-07-02T04:41:41Z")

</div>

That is most probably because you have links somewhere...

---

<div class="post-metadata">

**Author:** ![Jocker](https://community.unix.com/letter_avatar/jocker/32/6_449c533f586939b6e5f246632a46421f.png) [@Jocker](https://community.unix.com/u/Jocker)\
**Post date:** [July 2, 2009, 4:46am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/3 "2009-07-02T04:46:24Z")

</div>

Hi vbe, I've not link in input structures.

Have you any other suggestions or idea?

Tanks

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [July 2, 2009, 4:48am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/4 "2009-07-02T04:48:35Z")

</div>

The best would be you show us the passed command on what OS...

---

<div class="post-metadata">

**Author:** ![Jocker](https://community.unix.com/letter_avatar/jocker/32/6_449c533f586939b6e5f246632a46421f.png) [@Jocker](https://community.unix.com/u/Jocker)\
**Post date:** [July 2, 2009, 4:52am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/5 "2009-07-02T04:52:13Z")

</div>

OK, you are right! I'm sorry.  
I use HP-Unix as OS and the command submitted is tar -cvf directory\_name.tar directory\_name.

---

<div class="post-metadata">

**Author:** ![jayan\_jay](https://community.unix.com/user_avatar/community.unix.com/jayan_jay/32/1006_2.png) [@jayan\_jay](https://community.unix.com/u/jayan_jay)\
**Post date:** [July 2, 2009, 5:22am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/6 "2009-07-02T05:22:30Z")

</div>

Try this...  
tar -cvf directory\_name.tar directory\_name/\*

---

<div class="post-metadata">

**Author:** ![Jocker](https://community.unix.com/letter_avatar/jocker/32/6_449c533f586939b6e5f246632a46421f.png) [@Jocker](https://community.unix.com/u/Jocker)\
**Post date:** [July 2, 2009, 6:20am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/7 "2009-07-02T06:20:35Z")

</div>

Hi jayan\_jay, I already tryed to use this sintax, but the results is unchanged. Now I'm trying to use short directory name, because I think files path may be to be too long.

Another aspect of problem is that the syntax you suggest works if command is submitted by hand but doesn't work if submitted by command file.

Thanks

---

<div class="post-metadata">

**Author:** ![jayan\_jay](https://community.unix.com/user_avatar/community.unix.com/jayan_jay/32/1006_2.png) [@jayan\_jay](https://community.unix.com/u/jayan_jay)\
**Post date:** [July 2, 2009, 7:06am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/8 "2009-07-02T07:06:03Z")

</div>

Try to change the lengthy directory name and use it in a script.. If no use, then revert to proceed further..

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [July 2, 2009, 7:18am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/9 "2009-07-02T07:18:51Z")

</div>

Can you try with cpio to see if same problem occurs?

```nohighlight
find <directory> -print | cpio -ocv ><dirname>.cpio
To see the content...
cpio -cit< <dirname>.cpio

```

---

<div class="post-metadata">

**Author:** ![Jocker](https://community.unix.com/letter_avatar/jocker/32/6_449c533f586939b6e5f246632a46421f.png) [@Jocker](https://community.unix.com/u/Jocker)\
**Post date:** [July 2, 2009, 7:36am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/10 "2009-07-02T07:36:02Z")

</div>

cpio work correctly, but I cannot substitute tar with cpio because other scripts are based on a tar file.

---------- Post updated at 06:36 AM ---------- Previous update was at 06:33 AM ----------

javan\_jay the length of file path doesn't affect the behaviour of the command.

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [July 2, 2009, 11:49am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/11 "2009-07-02T11:49:43Z")

</div>

If cpio passes and not tar, then Im quite sure there is hidden links...  
so try again using tar's -l option (HPUX11.11 man:

> [@](#):
>
> l Tell tar to complain if it cannot resolve all of the links  
> to the files being saved. If l is not specified, no error  
> messages are printed.

---

<div class="post-metadata">

**Author:** ![Jocker](https://community.unix.com/letter_avatar/jocker/32/6_449c533f586939b6e5f246632a46421f.png) [@Jocker](https://community.unix.com/u/Jocker)\
**Post date:** [July 6, 2009, 11:19am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/12 "2009-07-06T11:19:47Z")

</div>

Hi vbe, I submitted tar command with -l options. No error and no warning were issued by tar.  
Bye

---------- Post updated at 10:19 AM ---------- Previous update was at 10:17 AM ----------

... and I'm sure that there's no link in the input structure (I've verified with ll -R command too)

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [July 7, 2009, 4:14am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/13 "2009-07-07T04:14:18Z")

</div>

Can you show us a example?  
What OS version and what architecture?  
what type of FS?  
If its VXFS have you tried to defragment the directories yet?

---

<div class="post-metadata">

**Author:** ![Jocker](https://community.unix.com/letter_avatar/jocker/32/6_449c533f586939b6e5f246632a46421f.png) [@Jocker](https://community.unix.com/u/Jocker)\
**Post date:** [July 7, 2009, 7:53am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/14 "2009-07-07T07:53:12Z")

</div>

Show an example may be very hard, because I'm try to tar a very big structure (992 files for over 1.5 GB). All what I can do is to send you a text file containing the output issued by tar, if you tell me how I can.  
I'm using HP-Unix B.11.00 on a RISC machine, FS is a VXFS type and I didn't try to defragment the directories before.  
In any case I can add another information. I tried to tar files beeing directly into the directory that contains them and tar returned a tar file as expected.  
Bye

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [July 7, 2009, 11:14am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/15 "2009-07-07T11:14:46Z")

</div>

Well show us the command you pass, and comment what is happening:is it the archive never finishes (because its looping..) or what...  
Very strange that if you go in the directory (that means now you user tar -cvf... \*, yes?) it works!

---

<div class="post-metadata">

**Author:** ![jksah](https://community.unix.com/letter_avatar/jksah/32/6_449c533f586939b6e5f246632a46421f.png) [@jksah](https://community.unix.com/u/jksah)\
**Post date:** [July 8, 2009, 8:13am UTC](https://community.unix.com/t/tar-command-loop-during-execution/243795/16 "2009-07-08T08:13:12Z")

</div>

have you tried ...

tar -cvf ../directory\_name.tar \*
