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-850558

kurokirasama's questions

Martin Hope
kurokirasama
Asked: 2021-10-21 05:28:52 +0800 CST

我无法让 bash 脚本保持活力

  • 0

我发现并稍微修改了以下脚本,该脚本监视notify-send通知并将它们转储到文件中。

#!/bin/bash

logfile=$1

dbus-monitor "interface='org.freedesktop.Notifications'" |\
 grep --line-buffered "string" |\
 grep --line-buffered -e method -e ":" -e '""' -e urgency -e notify -v |\
 grep --line-buffered '.*(?=string)|(?<=string).*' -oPi |\
 grep --line-buffered -v '^\s*$' |\
 ts |\
 xargs -I '{}' -d '\n' echo -e {} >> $logfile

如果我手动运行它:

notifylog notifylog.txt

该过程会持续工作一段时间,但最终会停止。如果我将它添加到 crontab 中,例如:

@reboot /path/to/file/notifylog /home/user/notifylog.txt

它执行一次然后停止(或者它最后一次运行很少)。

我什至尝试将其添加到启动应用程序中,例如:

/path/to/file/notifylog /home/user/notifylog.txt

和相同的结果。以下内容在手动执行但不能从 crontab 或启动应用程序执行时有效:

#!/bin/bash

logfile='/home/user/notifylog.txt'
rm -f $logfile
touch $logfile

while true; do /path/to/file/notifylog $logfile && break;done

我通过以下步骤添加到 systemd:

须藤纳米/lib/systemd/system/notifylog.service

然后我补充说:

[Unit]
Description=notify-send log

[Service]
ExecStart=/path/to/file/notifylog

[Install]
WantedBy=multi-user.target

然后:

sudo systemctl daemon-reload
sudo systemctl enable notifylog.service
sudo systemctl start notifylog.service
sudo systemctl status notifylog.service

最后一个给了我:

● notifylog.service - notify-send log
     Loaded: loaded (/lib/systemd/system/notifylog.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2021-10-20 19:01:49 -03; 3min 52s ago
    Process: 364180 ExecStart=/path/to/file/notifylog (code=exited, status=0/SUCC>
   Main PID: 364180 (code=exited, status=0/SUCCESS)

oct 20 19:01:49 mymachine systemd[1]: Started notify-send log.
oct 20 19:01:49 mymachine notifylog[364186]: Failed to open connection to session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
oct 20 19:01:49 mymachine systemd[1]: notifylog.service: Succeeded.

它似乎没有运行。

为此,我稍微修改了脚本:

#!/bin/bash

logfile='/home/user/notifylog.txt'
rm -f $logfile
touch $logfile

dbus-monitor "interface='org.freedesktop.Notifications'" |\
 grep --line-buffered "string" |\
 grep --line-buffered -e method -e ":" -e '""' -e urgency -e notify -v |\
 grep --line-buffered '.*(?=string)|(?<=string).*' -oPi |\
 grep --line-buffered -v '^\s*$' |\
 ts |\
 xargs -I '{}' -d '\n' echo -e {} >> $logfile

编辑:现在我通过以下步骤将它作为用户添加到 systemd

首先,将 .service 文件添加到/home/user/.config/systemd/user. 然后执行:

sudo systemctl daemon-reload
systemctl --user enable notifylog.service
systemctl --user start notifylog.service
systemctl --user status notifylog.service

这会正确启动服务,但是如果我重新启动机器,

systemctl --user status notifylog.service

给我:

● notifylog.service - notify-send log
     Loaded: loaded (/home/user/.config/systemd/user/notifylog.service; enabled; vendor preset: enabled)
     Active: inactive (dead)

我现在缺少什么?

bash
  • 2 个回答
  • 134 Views
Martin Hope
kurokirasama
Asked: 2020-06-25 17:32:55 +0800 CST

尝试在 ubuntu 20.04 上通过 tlmgr 安装乳胶包时出现错误,verify_checksum: -5

  • 5

我在 ubuntu 20.04 上安装了 texlive:

sudo apt -y install texlive-latex-extra texlive-extra-utils texlive-font-utils

尝试安装乳胶包(任何)时,我得到了:

/usr/bin/tlmgr: unexpected return value from verify_checksum: -5

有任何想法吗?

编辑:你好,我用tlmgr install package_name. tlmgr 安装乳胶时安装...的输出dpkg -S $(which tlmgr)

texlive-base: /usr/bin/tlmgr

输出apt-cache policy texlive-base:

texlive-base:
  Installed: 2019.20200218-1
  Candidate: 2019.20200218-1
  Version table:
 *** 2019.20200218-1 500
        500 http://cl.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
        500 http://cl.archive.ubuntu.com/ubuntu focal/universe i386 Packages
        100 /var/lib/dpkg/status

输出tlmgr --version:

tlmgr revision 53568 (2020-01-27 19:20:16 +0100)
tlmgr using installation: /usr/share/texlive
TeX Live (http://tug.org/texlive) version 2019
texlive 20.04
  • 2 个回答
  • 2986 Views
Martin Hope
kurokirasama
Asked: 2020-06-22 12:44:33 +0800 CST

创建 ubuntu 20.0 可启动 USB 磁盘时出现问题,启动创建器无法打开,bootiso 被冻结

  • 1

我必须在另一台机器上安装 ubuntu,所以我从 ubuntu 网页下载了 iso 并尝试按照教程创建可启动的 USB 棒,但启动磁盘创建器不会在我的 ubuntu 18.04 机器上打开,即使我删除和重新安装它。

所以我开始寻找一个 cli 替代方案并找到了这个工具:

curl -L https://git.io/bootiso -O
chmod +x bootiso
sudo apt install wimtools

我在我的iso上运行它并选择了usb设备,整晚都是这样: 截屏

所以,我想知道我是否可以在不杀死我的 USB 记忆棒的情况下杀死它,如果你能指出一个替代方案,那就太好了。在此期间,我会继续寻找。

live-usb
  • 1 个回答
  • 134 Views
Martin Hope
kurokirasama
Asked: 2018-08-17 05:24:53 +0800 CST

哪些关于 cpu 核心的信息是真实的?

  • 2

我对我机器上的实际 CPU 数量有疑问。不同的方法给我不同的结果...

htop显示 4 个核心工作

lscpu | grep CPU\(s\):显示 4

cat /proc/cpuinfo | grep processor显示 4

cat /proc/cpuinfo | grep "cpu cores" | uniq显示 2

sensors | grep Core显示 2

我有点失落……

编辑:

cat /proc/cpuinfo | grep 'model name'
model name  : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
cpuinfo 18.04
  • 1 个回答
  • 3599 Views

Sidebar

Stats

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

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve