简体   繁体   中英

How can I move an uploaded file from slave server to master server using php ssh connection?

My application is running in a master slave server. If a file upload request is going to slave server, I need to move that file to master server. Now it is only uploading to slave. It wont lsync with the master.

How can I move the uploaded file from the slave to master during the file upload time using ssh in php?

Server platform is ubuntu with apache and mysql.

I would suggest you to use rsync over ssh run by cron. First execute:

$ crontab -e

And add something like:

*/5 * * * * rsync -e 'ssh -i [identity_file]' [src_dir] [user]@[host]:[trg_dir]

This command will sync your directories every 5 minutes. Feel free to adjust '*/5 * * * *' pattern to your needs.

Finally:

$ man crontab

And:

$ man rsync

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM