Linux递归复制(Linux Copy recursively)

编程入门 行业动态 更新时间:2024-10-27 10:23:28
Linux递归复制(Linux Copy recursively)

每次我递归复制我总是用httpdocs文件夹而不是public_html中的文件。

例如,我可能运行如下:

cp -rpf /var/www/vhosts/website/httpdocs /var/www/vhosts/anotherwebsite/httpdocs

我总是最终使用/ var / www / vhosts / anotherwebsite / httpdocs / httpdocs,当我想要做的就是将网站从一个用户移动到另一个用户。

Every-time I copy recursively I always end up with httpdocs folder instead of the files within in public_html.

For example I might run something like:

cp -rpf /var/www/vhosts/website/httpdocs /var/www/vhosts/anotherwebsite/httpdocs

I always end up with /var/www/vhosts/anotherwebsite/httpdocs/httpdocs when all I am trying to do is move a website from one user to another.

最满意答案

当您只想“推送”本地网站而不会长时间离线时,您可以使用临时目录。

TODAY=$(date +%y%m%d) NEWCODE=/var/www/vhosts/anotherwebsite/docs_${TODAY} OLDCODE=/var/www/vhosts/anotherwebsite/docs_old rm -rf ${NEWCODE} cp -rpf /var/www/vhosts/website/httpdocs ${NEWCODE} || exit 1 # some checks ? cd /var/www/vhosts/anotherwebsite/ || exit 1 mv httpdocs ${OLDCODE} || exit 1 mv ${NEWCODE} httpdocs

在移动之间你将无法使用。 如果这是一个问题,您可能需要创建一个work_in_progress.html文件,将该文件重命名为httpdocs / index.html,删除所有其他文件并在此之后复制新文件(正确的index.html文件作为最后一个) 。 但这似乎很花哨,坚持上面的解决方案中的短暂的hickup。

When you just want to "push" your local website without getting offline long, you can use a temporary dir.

TODAY=$(date +%y%m%d) NEWCODE=/var/www/vhosts/anotherwebsite/docs_${TODAY} OLDCODE=/var/www/vhosts/anotherwebsite/docs_old rm -rf ${NEWCODE} cp -rpf /var/www/vhosts/website/httpdocs ${NEWCODE} || exit 1 # some checks ? cd /var/www/vhosts/anotherwebsite/ || exit 1 mv httpdocs ${OLDCODE} || exit 1 mv ${NEWCODE} httpdocs

Between the moves you will be unavailable. When that is a problem, you might want to make a work_in_progress.html file, rename that file to httpdocs/index.html, remove all other files and copy the new files after this (the correct index.html file as the last one). But this seems to fancy, stick with the short hickup in the solution above.

更多推荐

httpdocs,public_html,var,www,电脑培训,计算机培训,IT培训"/> <meta name="

本文发布于:2023-07-21 11:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1209771.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   Linux   recursively   Copy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!