远程部署项目时候,如果只改了一个class文件 则不需要部署整个项目,同步编译目录和目标目录即可

  1. mac 安装 fswatch,linux可以使用自带的 inotifywait
brew install fswatch

在这里插入图片描述

  1. 编写脚本 xxxx.sh

先设置ssh公钥登录远程服务器,这样每次同步不需要输入密码
参考 Mac使用ssh公钥免密登录Linux

~/PhpStorm/project / 本地目录
ip:/www/wwwroot/project/ 远程目录

#!/bin/bash
DIR=~/PhpStorm/project / 

if [ ! -n "$DIR" ] ;then
    echo "you have not choice Application directory !"
    exit
fi

fswatch $DIR | while read file
do
   echo "${file} was modify"
   rsync -avzrp ~/PhpStorm/project /  root@ip:/www/wwwroot/project/
done
  1. 运行脚本
    在这里插入图片描述
    不要关闭窗口,否则会中断进程,如果想后台运行使用 xxxx.sh & 后台挂起 即可

  2. 查看远程目录,同步成功


版权声明:本文为da13122318861原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/da13122318861/article/details/104183959