cp: cycle detected:

solaris

Solution

A cycle, when doing a recursive copy, is visiting the same "file" twice. This can be caused by links being set up in a circular manner. For example, if you make the directory `level1`:

mkdir level1

then symbolically link a file under there to that directory:

cd level1
ln -s . level2

you basically end up with a circular reference. That means you can do:

cd level2/level2/level2/...

to your heart's content and never leave the `level1` directory. This causes problems for a recursive copy since it would effective be an infinite loop.

You can use `cp -rH` or `cp -rP` (on Solaris 10 and above, I think) to not follow the symlinks.

Specifically, there are three flags you may be interested in:

`-H`: If the source_file operand is a symbolic link, then cp copies the file referenced by the symbolic link for the source_file operand. All other symbolic links encountered during traversal of a file hierarchy are preserved. This means that if the file/directory you specify as the source is a link, it will copy the target of that link. All symbolic links underneath that source will not be followed.

`-L`: Copies files referenced by symbolic links. Symbolic links encountered during traversal of a file hierarchy are not preserved. This will follow all symbolic links under the source.

`-P`: Copies symbolic links. Symbolic links encountered during traversal of a file hierarchy are preserved. I think this is identical to `-H` but also preserves the symbolic link for the specific source.

Problem

Any idea about cp: cycle detected: Error on Solaries. I am getting this while I am copying data from one directory to the another directory.

Original source