Strange Behavior with `rsync` in a Cron Job on CentOS 8 - Files Not Updating as Expected
I'm trying to debug I'm prototyping a solution and Quick question that's been bugging me - I'm experiencing an issue where a cron job running `rsync` on my CentOS 8 server is not updating files as expected... The goal is to synchronize files from `/var/www/myapp` to a remote backup server at `192.0.2.1:/backup/myapp`, but it seems that some files are being skipped even when they have changed. I set up the cron job as follows: ```bash * * * * * /usr/bin/rsync -avz /var/www/myapp/ user@192.0.2.1:/backup/myapp ``` When I check the cron logs, I see entries that suggest the job is running, but the output shows that it is not transferring changed files. I’ve tried running the `rsync` command manually, and it works perfectly, updating the files as expected. I’ve verified that the cron user has the necessary permissions and that there are no issues with SSH keys for authentication. The command in the cron job is being executed with the same user that has permissions to write to the destination directory. I also tried adding the `--ignore-existing` option to see if that affected the behavior, but it didn't help. I suspect there might be an issue with how the cron environment is set up compared to my interactive shell. For example, when I run the command manually, it uses a different set of environment variables. I've checked the `$PATH` in both environments, and they differ significantly. To troubleshoot, I've added the following lines to the cron job to log the environment variables: ```bash * * * * * env > /tmp/cron_env.txt; /usr/bin/rsync -avz /var/www/myapp/ user@192.0.2.1:/backup/myapp ``` The output shows that the `RSYNC_RSH` variable is not set in the cron environment. Could this be causing the issue? How can I ensure that my `rsync` command runs correctly in the cron job like it does interactively? Any insights would be greatly appreciated. Thanks for your help in advance!