我正在构建一个备份脚本,其中某些目录不应包含在备份存档中。
cd /;
find . -maxdepth 2 \
\( -path './sys' -o -path './dev' -o -path './proc' -o -path './media' -o -path './mnt' \) -prune \
-o -print
Run Code Online (Sandbox Code Playgroud)
这只会找到我想要的文件和目录。
问题是cpio
应该提供以下选项,以避免在恢复文件时出现权限问题。
find ... -depth ....
Run Code Online (Sandbox Code Playgroud)
如果我添加该-depth
选项,返回的文件和目录将包含我想要避免的文件和目录。
我真的不明白查找手册中的这些句子:
-prune True; if the file is a directory, do not descend into it. If
-depth is given, false; no effect. Because -delete implies
-depth, you cannot usefully use -prune and -delete together.
Run Code Online (Sandbox Code Playgroud) 有时,我必须根据 xsd 文件检查一些大型 xml 文件的有效性。我收到的最大 xml 文件的大小接近 1.5GB。
xmllint
占用了我所有的 RAM 和几乎所有的交换空间,总内存使用量为 18GB。因此,验证过程持续了 24 小时。
我的问题:是否有替代方案xmllint --schema
消耗更少的内存,也许利用一些流功能而不是将文件加载到内存?
我添加了一个新组:ircuser
和一个新用户:ircuser
在visudo
我放置这一行:
myuser localhost=(ircuser) NOPASSWD: /usr/bin/irssi
Run Code Online (Sandbox Code Playgroud)
创建的ircuser
目录,应保存配置文件、缓存等:
drwxrwx--- 2 ircuser ircuser 4096 Mar 2 10:28 ircuser
Run Code Online (Sandbox Code Playgroud)
发出命令时:
sudo -Hu ircuser /usr/bin/irssi
Run Code Online (Sandbox Code Playgroud)
或者
sudo -u ircuser /usr/bin/irssi
Run Code Online (Sandbox Code Playgroud)
程序无法将配置文件保存在ircuser
目录中。
** ERROR **: Couldn't create /home/myuser/_web/ircuser/.irssi directory
aborting...
Aborted
Run Code Online (Sandbox Code Playgroud)
但是,它正在运行ircuser
:
ps auxw | grep irssi
ircuser 11962 0.0 0.0 23684 2504 pts/6 S+ 11:18 0:00 /usr/bin/irssi
Run Code Online (Sandbox Code Playgroud)
那么,尽管irssi
运行ircuser
它不能写入同一用户拥有的目录?我需要更改什么才能让它保存在那里?