Animosity022, I tried to respond right after your last message but I was over the allowed number of messages for a new forum member. The message below is what I had intended to send:
Thanks, that is exactly what I am doing. This whole thread started with me asking if there was a code I could check, rather than parsing the log output. In a reply, calisro suggested that I check and see if the exit codes differed, depending on whether or not there have been changes. I determined that they do differ and updated my script.
The subsequent part of this thread sort of devolved into why I was using check instead of sync. For the most part it is because sync (actually I use copy) doesn’t change its exit code.
#!/bin/bash
Gdrive=/mnt/gdrive
LastRun="/home/plex/.cache/LastRun"
if [[ ! -f "$LastRun" ]]; then
touch $LastRun
fi
find "$Gdrive" -mindepth 1 -type f -cnewer $LastRun |
while read Path; do
echo "New/changed: $Path"
# do whatever you want here with it
done
touch $LASTRUNFILE
Thanks Ajki. Unless I misunderstand, your script is checking to see when it was last run. That is different than my use case, check and see if any files are different on the remote. I have written a script, the conditional part looks like this (“FMA” is just the name of the product that the files comprise):
#!/bin/bash
...
# next check to see if FMA processing needs to be done
# if not, exit
$(rclone check FMATeamDrive: $LATEST_DIR)
check=$?
if [[ $check == 0 ]]; then
echo "The FMA has NOT been modified "
else
echo "The FMA has been modified"
# since we are going to process the FMA, copy it down from Google Drive
rclone copy FMATeamDrive: "$LATEST_DIR"
# launch FMA processing script
# ...
fi
Actually it makes lastrun to compare time date of that file and then process only files that changed on remote.
So you could sync/copy only changed files