小编man*_*tor的帖子

组合 ^foo^bar 在 Bash 中有什么作用?

我最近看到一个视频,有人^foo^bar用 Bash执行死刑。那个组合有什么用?

bash

22
推荐指数
2
解决办法
3231
查看次数

kill -- -0 有什么作用?

是的,我已经看到已经有一个类似的问题,但是我遇到了kill -- -0并且想知道--在做什么?

linux process kill

13
推荐指数
2
解决办法
3905
查看次数

无法在 docker 容器中使用 PID 1 终止进程

我有以下 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)

process kill debian docker

13
推荐指数
1
解决办法
2万
查看次数

了解 shell 内置命令

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 -bbash 4.4,我会收到所有 shell 内置命令的列表。例如,我看到[并被kill列为 shell 内置函数。但他们的实际位置是:

/usr/bin/[
/bin/kill
Run Code Online (Sandbox Code Playgroud)

我认为这是builtin将命令编译为/bin/bash可执行文件的一种方式。那么真正让我感到困惑的是:请纠正我,但是builtin当一个单独的命令实际上不是 shell 的一部分时,它怎么可能是 a呢?

shell bash shell-builtin

12
推荐指数
2
解决办法
2947
查看次数

为什么运行`systemctl start 时退出状态不同;systemctl is-active` 和 `systemctl is-active` 分别是?

以下序列为我提供了第一个命令的返回值,而不是我预期的第二个(无论我是否在子 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() …

command-line bash exit-status

8
推荐指数
1
解决办法
3995
查看次数

如何找出 debconf-set-selections 的变量名称?

假设我想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 passwordmysql-server-5.5 mysql-server/root_password_again

我知道我可以.deb通过发出来提取包dpkg-deb -R package.deb EXTRACTDIR/- 但我没有看到这些变量的存储位置。

我如何找出debconf任何其他包的变量?

debian dpkg apt debconf

7
推荐指数
2
解决办法
6667
查看次数

创建 shell 脚本守护进程时,哪个 PID 属于 systemd PIDFile 部分?

我已经根据这个答案的代码创建了一个 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 …

process systemd daemon

7
推荐指数
2
解决办法
2万
查看次数

virNetSocketReadWire:1801:读取数据时文件结束:输入/输出错误

每次启动/停止 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)

有没有人遇到同样的问题?

kvm virtual-machine libvirt

7
推荐指数
1
解决办法
3504
查看次数

如何使用 docker-compose.yml 版本 3 指定静态 IP 地址?

有人在这里问了同样的问题- 问题是它与2我没有使用的版本有关。同时是否可以在docker-compose.yml文件中使用 docker-compose 为每个启动的容器定义一个静态子网和一个静态 IP 地址?

docker

5
推荐指数
1
解决办法
1万
查看次数

bzip2:检查文件的解压大小而不实际解压

我有一个很大的bzip2压缩文件,我需要检查它的解压缩大小而不实际解压缩它(类似于gzip -l file.gzxz -l file.xz)。这如何使用bzip2

compression bzip2

5
推荐指数
1
解决办法
1909
查看次数