Requirement

Our requirement is to copy all files created in directory to other directory with same directory structure. Script will run on a regular interval, search for all files created in source directory and copy them to destination directory. The script must maintain the same directory structure on destination directory. After that change the permission on destination directory. After successful copy of file, script must remove the file from source directory.

Shell Script

Create a shell script on your system and add below content. Update source and destination directories to proper location. Set CHANGE_OWNERSHIP to 0, if you don’t want to change ownership on destination files.

Save your file and close it. Then set the execute permission to the script file.