I want to run a rsync command between two servers on reboot can anyone suggest how can i do this?


#1

I want to run a rsync command between two servers on reboot can anyone suggest how can i do this??


#2

Before the reboot or after the reboot?

If after the reboot just put an entry in cron, either crontab or cron.d with the time entered as "@reboot"

For example:
"@reboot /root/tools/some_action 1>>/some_log_file 2>>/some_error_file"

I have never done it before the reboot, but you could put in a custom shutdown script to perform the action.


#3

Thanks @jvossler I'll try this one.


#4

Is there any other work around for this ??


#5

Did the cron entry not perform the action?

Under Chef I would use a cron.d as a separate file controlled by a single Chef resource. For cron.d remember that you need to enter the account to run the command as in the entry.


#6

Are these physical servers or virtual? If virtual, have you thought about using a shared drive? Then don’t need to sync. In AWS, you could use a shared s3 or EFS. If they are physical machines you could do an NFS share, maybe backed by some tech like DRBD or GlusterFS, or even SMB.