I want to rsync files from one server to another server every 5 minutes, but only want to start the rsync if the previous rsync command has finished. Time for one rsync depends on how much data changed on the source server, so the time taken to finish rsync cronjob varies.
Create file rsync.sh
#!/bin/bash if ! pgrep -x "rsync" > /dev/null then rsync -avzP /var/www/html/files/ [email protected]:/var/www/html/files/ fi
Set cronjob like
*/10 * * * * /root/rsync.sh > /dev/null
Leave a Reply