我正在阅读一些通过 SSH 客户端发送文件的 Go 代码。
https://github.com/tmc/scp/blob/master/scp.go#L33
它所做的一件事是将scp -t /remote/path
. 那-t
旗子是干什么用的?我做了一个man scp
,但似乎没有记录。我在本地运行了命令,它的行为似乎像 cat。
scp -t
远程运行后,代码会像这样将字节发送到服务器。
// Some special control header? What is this?
fmt.Fprintf(w, "C%#o %d %s\n", mode, size, fileName)
// Send file bytes.
io.Copy(w, contents)
// Send termination signal?
fmt.Fprint(w, "\x00")
Run Code Online (Sandbox Code Playgroud)
这个协议是什么?它在任何地方都有记录吗?
假设我只想保留最近 10 天的日志。
我必须跑吗
journalctl --vacuum-time=10d
Run Code Online (Sandbox Code Playgroud)
每天都有计时器吗?我还需要使用吗--rotate
?“旋转日志文件”是什么意思?
我可以设置一些东西吗/etc/systemd/journald.conf
?我正在阅读man 5 journald.conf
,但似乎SystemMaxUse
只接受字节,而不接受时间。
我不关心文件的大小或数量。正好记录日志的时间。
我试图理解为什么有些 Makefile 具有先决条件,%.txt
而其他 Makefile 则具有*.txt
.
我已经创建了这个文件夹布局。
\n$ tree .\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hi1.txt\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hi2.txt\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hi3.txt\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Makefile\n
Run Code Online (Sandbox Code Playgroud)\n首先,我尝试了这个。
\nfoo.txt: *.txt\n echo $^\n
Run Code Online (Sandbox Code Playgroud)\n它达到了我的预期。
\n$ make\necho hi1.txt hi2.txt hi3.txt\nhi1.txt hi2.txt hi3.txt\n
Run Code Online (Sandbox Code Playgroud)\n但是,后来我看到一些 Makefile 用作%.txt
通配符。所以我接下来尝试了。
foo.txt: %.txt\n echo $^\n
Run Code Online (Sandbox Code Playgroud)\n但是,这会导致错误。
\n$ make\nmake: *** No rule to make target '%.txt', needed by 'foo.txt'. Stop.\n
Run Code Online (Sandbox Code Playgroud)\n有人可以解释为什么会发生这种情况吗?
\nGNU Make 4.3
\n我正在运行一个命令来查找目录中的所有 make 文件并运行make build
.
我想xargs
在第一个make build
失败时停止。
这是我到目前为止的命令。
$ find . -name "Makefile" | xargs dirname | xargs -I {} make -C {} build
Run Code Online (Sandbox Code Playgroud)
问题是,xargs
即使make build
失败了,它仍然会继续下去。当我检查最终状态代码时,我看到的是以下内容。
$ echo $?
123
Run Code Online (Sandbox Code Playgroud)
当我检查手册页时。这就是它所说的。
123 if any invocation of the command exited with status 1-125
Run Code Online (Sandbox Code Playgroud)
这是有道理的,因为其中一些因make build
exit 1 或其他原因而失败。
有没有办法xargs
在第一个make build
错误时停止?