I have a script, which is supposed to run 1 day of the month, connect to remote server certain directory, find files, tar the, and copy
find . -ctime -1 | tar -cvf transfer_dmz_start_monthly.tar *${Today}*.*;
if [ $? != 0 ]
then
echo "Cannot create a tar file, the terminated abnormaly"
exit 1
fi
gzip transfer_dmz_start_monthly.tar
/usr/bin/scp ${DESTSERVNAME}:${MONTH_DEST_DIR}/${TARGZFILE} ${LOCL_FILES_DIR}/cool_${Today}/monthly
Now problem was changed
I have to check if directory has files for Today's day. If not - exit, if yes, then logic above.
Is below code will work?
if [ `ls | wc -l` = 0 ]
then
exit
else
find . -ctime -1 | tar -cvf transfer_dmz_start_monthly.tar *${Today}*.*;
fi
Or you can find something better.
I am on AIX and have no bash
BTW, it will always have archived files , which I don't need. I.e. probably
ls ${Today}
Thanks for contribution