copy a file slowly and catch an error when fails on unix

There is a production mainframe job that copy a file between 2AM to 2:30AM on Unix.  Sometimes, the job fails without giving out any error.  

I would like to mimic the copy to find out the error.  So, I am thinking to schedule a unix job to copy a small file ( or ftp a file or something similar) between 2AM to 2:30AM.  I don't want to copy a large file though for 30 minutes.  Is there a way to consistently copy a small file over and over again or copy a small file slowly?  What is the command to catch error message when error occurs?

Who is Participating?
omarfaridConnect With a Mentor Commented:
if you copy file with command cp then you can always check command exit code:

cp file1 file2

if [ $? -EQ 0 ]
    echo successful
     echo there was an error
ewang1205Author Commented:
Can I echo the error?  Thanks.
Well, if there is an error then the command / tool should produce the error message.
gheistConnect With a Mentor Commented:
> Can I echo the error?

echo $?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.