I am using the following code
if [ ! -f $time_mark ]
then
touch $time_mark
fi
cp -f aaa.txt bbb.txt ccc.txt $file_dir
find $file_dir -newer $time_mark > file_list.txt
...
I am using find -newer to send only files are that copied later than $time_mark. But it turns out that if $time_mark does not exist for first time, it will execute touch $time_mark and start copying files, which can happen almost at the same time. This results in $time_mark and copied files having the same system time, and the whole concept of sending only files copied later than $time_mark doesn’t work.
Is there some way to work around this problem?
Thanks
Even better would seem to execute the touch conditionally (only if the prior run succeeded?)
I strongly suggest to look at
rsync,rdiff-backup, or other (backup?) tools that grok incremental change detection.As a very simple measure, since you seem to hint you want to copy these files (?) somewhere, simply copying with
-pu(--preserve=mode,ownership,timestamps --update) could do the trick