script to check files,change the file permissions and move it to folder
Need help on the below requirement:
we are using to move files for archive process.The script list the files, change the permission on the file and moving it to a different folder. Sometimes the script is moving the file before the contents fully generated. We need to add a delay after getting the list before starting the loop. Is this possible?
we don’t want to add delay in the loop as it will slow down the process.
Ex:The requirement is We need to get the list of files that are fully transferred to the location
and then we need to change permissions and move those files to the target directory.
lets say we have a file 'X' which is completely transferred and creation time is 2:30PM and we have another file 'Y' for which the contents are still loading to the file then creation time will be "2:35PM". So, in this case, we have to take only the 1st file i.e., 'X' and change the permissions and move it to archive folder.
### Script to change the file permissions and move it to folder
# function starts here
if [ "$?" = "0" ]; then
for i in $(/usr/bin/ls *)
echo "ext: changing file permission $i"
/usr/bin/chmod 775 $i
echo "ext: Moving $i"
/usr/bin/mv $i $OUT_DIR/$i
echo "Error accessing folder " $IN_DIR
### program starts here #################
Thanks in advance,