AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-9259

starfry's questions

Martin Hope
starfry
Asked: 2022-12-10 05:21:01 +0800 CST

在 shell 管道中捕获进程信号“已终止”消息输出

  • 5

当进程被信号结束时,将输出一条消息,类似于Terminated或Killed取决于所使用的信号。是否可以捕获该消息?

以这个示例管道为例:

while true; do timeout 2 sleep 5; done

它没有输出,但是sleep每 2 秒终止一次。添加一个cat:

while true; do timeout 2 sleep 5 | cat; done

它现在Terminated每 2 秒输出一次但cat看不到它 - 如果我替换cat为tee somefile然后文件仍然为空。

我试过2>&1在命令行的不同地方重定向,但我无法将Terminated输出放入文件中。

我认为它们是通过libc链接输出到终端的 shell 而不是循环中的命令。

是否有可能将 theTerminated和类似的 outout 放入管道中?

(最终,我想将sleepacurl和a 替换为cat一个awk脚本,该脚本同时处理curl输出和Terminated消息。)

shell
  • 1 个回答
  • 25 Views
Martin Hope
starfry
Asked: 2018-09-08 05:18:23 +0800 CST

使用 su 捕获 scrot 命令输出

  • 1

我想捕获使用scrot创建的图像文件的名称。我可以像这样捕获文件名:

$ image=$(scrot -s -e 'echo $n')
$ echo $image
2018-09-07-140419_185x76_scrot.png

我需要通过以下方式做到这一点su:

$ image=$(su someuser -c "scrot -s -e 'echo $n'")

然而,image是空的。

我认为这种语法是正确的 - 这有效:

$ greeting=$(su someuser -c "echo 'hello, world'")
$ echo $greeting
hello, world

我不确定为什么这不起作用scrot。我认为它与如何scrot启动它的子外壳有关 - 我猜它不会传播它的输出?

shell-script su
  • 1 个回答
  • 436 Views
Martin Hope
starfry
Asked: 2018-06-23 02:45:53 +0800 CST

检查 VMware Workstation 14 所需的 VMX Unrestricted Guest IA-32e?

  • 0

有没有办法在不安装 vmware 的情况下从 Linux 中检查是否存在VMware Workstation 14 要求的“ VMX Unrestricted Guest ”支持?

virtual-machine vmware-workstation
  • 1 个回答
  • 845 Views
Martin Hope
starfry
Asked: 2018-06-06 02:51:14 +0800 CST

如何创建 GRUB 可以读取的 ZFS zpool

  • 7

Arch Linux ZFS wiki 页面解释了与 grub 兼容的池创建,这个关于引导 Fedora 的页面也是如此,但我无法创建 Grub 可读的池。关于在 ZFS 上安装 Arch Linux的 Arch Linux wiki 页面突出显示了某些错误,但并没有真正解释如何克服这些错误。

链接页面说明 Grub 支持zpool 功能的子集,并且无法读取使用它不支持的功能的池。他们继续解释如何配置合适的池,但我无法使其工作。支持的功能子集似乎没有在任何地方记录。

我正在使用虚拟机测试 Grub 2.02 和 Arch Linux 内核 4.16.13-1-ARCH,这是最新的并且与当前的zfs-linux包版本 ( zfs-linux-0.7.9.4.16.13.1-1) 兼容。我(还没有)尝试制作可引导系统,只是为了证明 Grub 可以读取 zpool。这是我尝试过的:

首先,就像arch wiki 页面建议的那样,通过禁用不需要的功能:

# zpool create \
    -o feature@multi_vdev_crash_dump=disabled \
    -o feature@large_dnode=disabled           \
    -o feature@sha512=disabled                \
    -o feature@skein=disabled                 \
    -o feature@edonr=disabled                 \
    testpool mirror \
    /dev/disk/by-id/ata-VBOX_HARDDISK_VB{5f2d4170-647f16b7,f38966d8-57bff7df}

这导致了这些功能:

testpool  feature@async_destroy          enabled                       local
testpool  feature@empty_bpobj            active                        local
testpool  feature@lz4_compress           active                        local
testpool  feature@multi_vdev_crash_dump  disabled                      local
testpool  feature@spacemap_histogram     active                        local
testpool  feature@enabled_txg            active                        local
testpool  feature@hole_birth             active                        local
testpool  feature@extensible_dataset     active                        local
testpool  feature@embedded_data          active                        local
testpool  feature@bookmarks              enabled                       local
testpool  feature@filesystem_limits      enabled                       local
testpool  feature@large_blocks           enabled                       local
testpool  feature@large_dnode            disabled                      local
testpool  feature@sha512                 disabled                      local
testpool  feature@skein                  disabled                      local
testpool  feature@edonr                  disabled                      local
testpool  feature@userobj_accounting     active                        local

然后,像fedora 示例一样,通过启用想要的功能:

zpool create -d \
    -o feature@async_destroy=enabled \
    -o feature@empty_bpobj=enabled \
    -o feature@spacemap_histogram=enabled \
    -o feature@enabled_txg=enabled \
    -o feature@hole_birth=enabled \
    -o feature@bookmarks=enabled \
    -o feature@embedded_data=enabled \
    -o feature@large_blocks=enabled \
    testpool mirror \
    /dev/disk/by-id/ata-VBOX_HARDDISK_VB{5f2d4170-647f16b7,f38966d8-57bff7df}

这导致了这些功能:

# zpool get all testpool | grep feature
testpool  feature@async_destroy          enabled                       local
testpool  feature@empty_bpobj            active                        local
testpool  feature@lz4_compress           disabled                      local
testpool  feature@multi_vdev_crash_dump  disabled                      local
testpool  feature@spacemap_histogram     active                        local
testpool  feature@enabled_txg            active                        local
testpool  feature@hole_birth             active                        local
testpool  feature@extensible_dataset     enabled                       local
testpool  feature@embedded_data          active                        local
testpool  feature@bookmarks              enabled                       local
testpool  feature@filesystem_limits      disabled                      local
testpool  feature@large_blocks           enabled                       local
testpool  feature@large_dnode            disabled                      local
testpool  feature@sha512                 disabled                      local
testpool  feature@skein                  disabled                      local
testpool  feature@edonr                  disabled                      local
testpool  feature@userobj_accounting     disabled                      local

在每种情况下,我都加载了一些内容:

# cp -a /boot /testpool

然后,重新启动到 Grub:

grub> search --set --label testpool
grub> ls /
@/
grub> ls /@
error: compression algorithm 80 not supported
.
grub> ls /@/
error: compression algorithm inherit not supported
.

我尝试启用/禁用某些功能,尤其是lz4_compress. 我还尝试在池中创建数据集。我在 Grub 中尝试过的一切都没有。

我希望能够列出/boot或/@/boot。

遇到的错误包括

  • compression algorithm inherit not supported
  • compression algorithm 66 not supported
  • compression algorithm 80 not supported
  • incorrect dnode type

应该如何创建 ZFS zpool 以便 Grub 可以读取它?

arch-linux grub2
  • 2 个回答
  • 8127 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve