Copy Script Stops

Good Morning,

I have a copy script on Solaris 9 machine that is supposed to copy some files to a NAS using:

cp -r /dir/dir/ /dir/dir/dir

The script doesn't finish. The directory contains user files of which one seems to copy fine, a second was failing until I did a

chmod -R -777

to it. Now, the copy looks the same as far as I can tell, but the directory for the next users never get created and the script seems to stop. Any ideas why? Normally

crontab

runs this script, but I am running it manually from root right now.

This command as written

chmod -R -777

Makes every file + directory (affected by the command) unaccessable. So I do not know what you are trying to do.

Try changing the -777 to 777.

1 Like

Sorry typo there was no -. When I ls -l everything looks right.

I tried

cp -r /dir/dir/dir /dir/dir/dir 2>&1 

and no error was reported but it stopped at the same user.

Firstly, it is known that:

# cp -r <whatever>

can have problems with special files (device nodes e.g. /dev/<whatever>) and also with linked files.

So does including the -v switch (verbose) tell you any more?

# cp -rv <whatever>

If no success then try -R instead.

# cp -Rv <whatever>

Read the man page for cp to see the difference.

# man cp

If that all fails, then substitute the cp for a find/cpio combination to copy your directory tree:

# cd /dir/dir/<top of tree to be copied>
# find . -depth -print|cpio -puvdm <target directory>

Note: In the above the <target directory> MUST already exist before the command is issued.

See if that does the job. Do let us all know the outcome.

1 Like

Under which user account did you run the script? If it was not root this might have been the problem.

Furthermore, to copy a (sub-)tree recursively it is generally better to use tar instead of cp -r :

cd /path/to/source ; tar -cf - * | (cd /path/to/target ; tar xf -)

will copy all files and directories in /path/to/source to /path/to/target AND it will preserve all filemodes and ownership properties.

I hope this helps.

bakunin

1 Like

Thanks everyone.. Its working now.

cp -R

not

cp -r

I'm not piping anything so I'm not sure why it works.. but it works.

I'll read up on tar anyway- I've never used it.