是的,我已经看到已经有一个类似的问题,但是我遇到了kill -- -0
并且想知道--
在做什么?
我有以下 Dockerfile 用于创建一个包含 powerdns 递归的容器:
FROM debian:stretch-slim
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install --no-install-recommends -y \
pdns-recursor && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
COPY ./configuration/recursor.conf /etc/powerdns/recursor.conf
RUN chown -R :pdns /etc/powerdns/ && \
chmod 0750 /etc/powerdns/ && \
chmod 0640 /etc/powerdns/recursor.conf
EXPOSE 8699
ENTRYPOINT ["/usr/sbin/pdns_recursor", "--daemon=no"]
Run Code Online (Sandbox Code Playgroud)
我的recursor.conf
看起来像这样:
config-dir=/etc/powerdns
forward-zones=resolver1.opendns.com=208.67.222.222
hint-file=/usr/share/dns/root.hints
local-address=0.0.0.0
local-port=8699
quiet=yes
security-poll-suffix=
setgid=pdns
setuid=pdns
Run Code Online (Sandbox Code Playgroud)
虚拟机管理程序上禁用了 IPv6。
问题是 docker 无法使用docker stop recursor
. 一段时间后,OOMKiller 使用以下信息终止程序:
Exited (137) 2 seconds …
Run Code Online (Sandbox Code Playgroud) 在bash 手册中,它写道
Builtin commands are contained >>> within <<< the shell itself
Run Code Online (Sandbox Code Playgroud)
此外,这个答案指出
A built-in command is simply a command that the shell carries out itself,
instead of interpreting it as a request to load and run some
>>> other program <<<
Run Code Online (Sandbox Code Playgroud)
当我运行compgen -b
时bash 4.4
,我会收到所有 shell 内置命令的列表。例如,我看到[
并被kill
列为 shell 内置函数。但他们的实际位置是:
/usr/bin/[
/bin/kill
Run Code Online (Sandbox Code Playgroud)
我认为这是builtin
将命令编译为/bin/bash
可执行文件的一种方式。那么真正让我感到困惑的是:请纠正我,但是builtin
当一个单独的命令实际上不是 shell 的一部分时,它怎么可能是 a呢?
以下序列为我提供了第一个命令的返回值,而不是我预期的第二个(无论我是否在子 shell 中运行第一个命令):
sudo systemctl start x; sudo systemctl is-active --quiet x; echo $?;
(sudo systemctl start x); sudo systemctl is-active --quiet x; echo $?;
Run Code Online (Sandbox Code Playgroud)
该服务x
已损坏且无法启动 - 所以他没有运行。以下独立运行的命令为我提供了正确的返回值,3
因为它应该是:
sudo systemctl is-active --quiet x; echo $?;
Run Code Online (Sandbox Code Playgroud)
那么,为什么我0
在运行时得到第一个命令 ( )command; command; echo $?
的返回值而不是第二个命令的返回值 ( 3
)echo $?
呢?
我在GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
。我知道,如果我将它分成 2 行,它会起作用:
sudo systemctl start x;
sudo systemctl is-active --quiet x; echo $?;
Run Code Online (Sandbox Code Playgroud)
但是我需要将它作为单行,因为我将它放在 PHPshell_exec()
函数中。运行两次shell_exec() …
假设我想mysql
从脚本安装,而不会被问到任何配置问题,比如我想设置什么 root 密码apt
。然后我会预设debconf
变量:
echo mysql-server-5.5 mysql-server/root_password password xyzzy | debconf-set-selections
echo mysql-server-5.5 mysql-server/root_password_again password xyzzy | debconf-set-selections
Run Code Online (Sandbox Code Playgroud)
我从教程中得到了这个。我不清楚的是:这家伙是如何找出变量名称的?他怎么知道他必须分别设置mysql-server-5.5 mysql-server/root_password password
和mysql-server-5.5 mysql-server/root_password_again
?
我知道我可以.deb
通过发出来提取包dpkg-deb -R package.deb EXTRACTDIR/
- 但我没有看到这些变量的存储位置。
我如何找出debconf
任何其他包的变量?
我已经根据这个答案的代码创建了一个 shell 脚本守护进程。我写了一个 systemd 服务文件,内容如下:
[Unit]
Description=My Daemon
After=network.target
[Service]
Type=forking
PIDFile=/run/daemon.pid
ExecStart=/root/bin/daemon.sh
ExecReload=/bin/kill -1 -- $MAINPID
ExecStop=/bin/kill -- $MAINPID
TimeoutStopSec=5
KillMode=process
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
就在 while 循环开始之前,我正在创建一个 PID 文件(它将由守护进程创建,而不是由子进程或父进程创建,因为它们还没有达到这一点):echo $$ > /run/daemon.pid;
. 它工作正常,但每次我打电话时systemctl status daemon.service
,我都会收到以下警告:
daemon.service: PID file /run/daemon.pid not readable (yet?) after start: No such file or directory
Run Code Online (Sandbox Code Playgroud)
如果我echo $$ > /run/daemon.pid;
在脚本的开头插入 PID creaton 语句(子级和父级也将使用它),我会收到以下警告:
daemon.service: PID 30631 read from file /run/daemon.pid does not exist or is a zombie.
Run Code Online (Sandbox Code Playgroud)
创建 PID …
每次启动/停止 KVM 时,都会libvirtd 3.0.0-4
在系统日志中引发以下错误:
libvirtd[3145]: 2018-08-07 21:00:19.699+0000: 3145: \
error : qemuMonitorIO:710 : internal error: \
End of file from qemu m onitor
virtlogd[2753]: 2018-08-07 21:00:19.901+0000: 2753: \
error : virNetSocketReadWire:1801 : \
End of file while reading data: Input/output error
Run Code Online (Sandbox Code Playgroud)
有没有人遇到同样的问题?
有人在这里问了同样的问题- 问题是它与2
我没有使用的版本有关。同时是否可以在docker-compose.yml
文件中使用 docker-compose 为每个启动的容器定义一个静态子网和一个静态 IP 地址?
我有一个很大的bzip2
压缩文件,我需要检查它的解压缩大小而不实际解压缩它(类似于gzip -l file.gz
或xz -l file.xz
)。这如何使用bzip2
?