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
    • 最新
    • 标签
主页 / server / 问题

问题[stdout](server)

Martin Hope
gctwnl
Asked: 2022-10-30 04:32:22 +0800 CST

如何将 lighttpd 访问日志获取到标准输出?

  • 5

我lighttpd在 Ubuntu 上的 docker 容器中运行(作为我的设置中必须始终启动的服务traefik)。我的docker-compose.yml包含:

  lighttpd:
    image: sebp/lighttpd
    container_name: lighttpd
    restart: unless-stopped
    volumes:
      - /srv/docker/traefik/lighttpd/etc/lighttpd.conf:/etc/lighttpd/lighttpd.conf
      - /srv/docker/traefik/lighttpd/log/error.log:/var/log/lighttpd/error.log
      - /srv/docker/traefik/lighttpd/log/access.log:/var/log/lighttpd/access.log
      - /var/www/miniserver/html/:/var/www/html/
    ports:
      - "80"
    tty: true
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.lighttpd.rule=Host(`foo.rna.nl`)"
      - "traefik.http.routers.lighttpd.entrypoints=web"
      - "traefik.http.routers.lighttpd.tls=false"
    networks:
      - proxy

lighttpd工作,为我服务index.html,但是:

# docker logs lighttpd
2022-10-29 12:13:55: (server.c.1568) server started (lighttpd/1.4.64)

我收到启动消息,但没有别的。当我将访问日志定向到文件时,我会在那里获得访问日志条目:

172.26.0.2 foo.rna.nl - [29/Oct/2022:11:53:02 +0000] "GET /index.html HTTP/1.1" 200 37 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15"

如何将lighttpd访问日志定向到标准输出?我尝试了这两个:

accesslog.filename = "/proc/self/fd/1"
accesslog.filename = "/dev/stdout"

我的完整lighttpd.conf:

server.modules = (
    "mod_indexfile",
    "mod_access",
    "mod_alias",
    "mod_redirect",
    "mod_accesslog",
)

server.document-root = "/var/www/html" 
#server.errorlog = "/var/log/lighttpd/error.log"
server.port = 80

mimetype.assign = (
  ".html" => "text/html", 
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png" 
)

accesslog.filename = "/proc/self/fd/1"
#accesslog.filename = "/dev/stdout"
#accesslog.filename = "/var/log/lighttpd/access.log"
lighttpd stdout
  • 1 个回答
  • 23 Views
Martin Hope
Bil5
Asked: 2021-08-06 02:30:17 +0800 CST

在 Debian 无人值守预置安装期间向用户显示消息

  • 2

在late_command无人值守安装的步骤中,我正在运行一个 shell 脚本:

d-i preseed/late_command string in-target /bin/sh -c './execute-script.sh'

当达到 late_command 步骤时,UI(蓝色背景,灰色窗口)显示“正在运行 preseed...”消息:

在此处输入图像描述

我想知道是否有任何方法可以根据execute-script.sh正在做的事情来生动地显示其他消息。

我天真地认为使用带有回声的常规 STDOUT 可以解决问题,但它似乎更复杂。

到目前为止,我的搜索引起了我的注意,debconf但我还没有找到任何方法。

我的脚本的当前版本根据@Andrew 的答案重新调整:

#!/bin/sh

. /usr/share/debconf/confmodule
. "./variables.sh"

logFile="/target${INSTALLATION_LOG_LOCATION}"
templatePath="/target/tmp/deployment_progress_tracker.templates"

cat > "${templatePath}" << 'EOF'
Template: deployment_progress_tracker/progress/fallback
Type: text
Description: ${STEP}...
EOF

debconf-loadtemplate deployment_progress_tracker "${templatePath}"
db_progress START 0 1 deployment_progress_tracker/progress

watchLogs () {
  deploymentDone=false
  while ! $deploymentDone
  do
    if [ -f "${logFile}" ]; then
      step=$(grep -E -o -a -h "Progress-step: .*" "${logFile}" | tail -1 | sed 's/Progress-step: //')
      if [ -z "${step##*$DEPLOYMENT_FINISHED*}" ]; then
        deploymentDone=true
      elif [ -n "${step}" ]; then
        db_subst deployment_progress_tracker/progress/fallback STEP "${step}"
        db_progress INFO deployment_progress_tracker/progress/fallback
      fi
    fi
    sleep 3
  done
}



(
  watchLogs;
  rm -f "${templatePath}";
  db_progress SET 1;
  sleep 1;
  db_progress STOP;
  db_unregister deployment_progress_tracker/progress;
) &

前面的脚本将产生以下结果:

在此处输入图像描述

并返回安装程序菜单(选择完成安装实际上将再次运行预置部分并失败,选择中止不会卸载 ISO 并重新启动,无论如何,我正在尝试自动完成卸载和重新启动):

在此处输入图像描述

debian unattended stdout preseed debconf
  • 1 个回答
  • 413 Views
Martin Hope
Guerrilla
Asked: 2021-02-21 21:30:49 +0800 CST

Supervisord 服务未输出到 docker-compose 控制台

  • 0

我有一个 docker 容器,它在其中运行多个服务。我希望每个服务都将其输出发送到控制台。这是一个开发容器,所以我想在工作时查看所有输出。

我试过这个文件:

[supervisord]
nodaemon=true
 
[program:sshd]
command=/usr/sbin/sshd -D
autostart=true
autorestart=true
 
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
priority=900
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
username=www-data
autorestart=true
autostart=true

[program:php-fpm]
command=/usr/sbin/php-fpm7.4 -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=5


[program:memcached]
command=/usr/bin/memcached -u root
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=200

但它只输出supervisord消息,而不是来自服务的消息。我看到另一个线程向其中发送日志消息,/dev/fd/1所以我也尝试了,但没有成功。

stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

我的基础镜像是 ubuntu 20.04。

为什么我不能将服务日志消息输入控制台?

docker supervisord stdout
  • 1 个回答
  • 1891 Views
Martin Hope
TheCooocy
Asked: 2021-01-13 02:59:19 +0800 CST

stdout 不显示没有重定向的 `rpm -qa` 输出

  • 0

在 SLES 12 虚拟机上,该命令rpm -qa不会向标准输出返回任何内容。

~> rpm -qa
~>

该命令在 1 或 2 秒后完成,因此它清楚地生成了一些数据。只有当输出被重定向到文件或通过管道时,它才会变得可见:

~> rpm -qa > out.txt      # works fine
~> rpm -qa | grep lib
libgcc ...
...

问题不在于 rpm 数据库,其中的数据库文件/var/lib/rpm/存在并且看起来很健康,此处建议的重建并不能解决问题。

rpm sles sles12 stdout
  • 1 个回答
  • 61 Views
Martin Hope
The amateur programmer
Asked: 2020-07-29 07:09:50 +0800 CST

Linux 做 STDOUT | STDIN管道将数据写入磁盘?

  • 0

我正计划zfs load-key pool/set通过标准输入传递加密密钥。传递的密钥由另一个 HEX 格式的程序生成,并且数据集被配置为具有keylocation=prompt, keyformat=hex,因此密钥可以通过标准输入传递,如下所示someprogram | zfs load-key pool/set:

现在我担心即使我真的不希望这种情况发生,shell 是否有可能将这个传递的密钥数据写入磁盘的某个位置?如果在将 STDOUT 传输到 STDIN 的过程中将密钥写入磁盘的某个位置,那么它可能会被恢复,因为主 os 磁盘本身没有加密。

shell pipe zfsonlinux stdout stdin
  • 1 个回答
  • 240 Views
Martin Hope
jython.li
Asked: 2016-08-03 02:07:46 +0800 CST

使用“exec 1>ok.log”时,如何在 shell 脚本中将指定的内容输出到屏幕?

  • 0

如下,我只希望命令echo "this is to stdout"输出到我的屏幕而不是文件ok.log,我该怎么办?
我搜索了execshell命令的用法,但没有结果,请指教

[root@161 tmp]# bash --version
GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.

[root@161 tmp]# cat 2.sh
#!/bin/bash
exec 1>ok.log
exec 2>error.log
#exist dir
ls /home/
#no exist dir
ls /etca/
#to stdout
echo "this is to stdout"
#other cmds
...
shell stdout exec
  • 1 个回答
  • 632 Views
Martin Hope
Barooh
Asked: 2012-06-08 02:12:44 +0800 CST

如何将标准输出同时输出到进程和 shell 屏幕

  • 0

有人知道将命令的标准输出发送到另一个命令并将其显示在 shell 屏幕上的方法吗?注意:不使用文件。

一个例子(在这种情况下我使用 wc -l 来简化它)

~> echo "test" | wc -l
1

但我需要有

test
1

我试过 tee 命令,希望它能做到,但它返回同样的东西

~> echo "test" | tee | wc -l
1

有任何想法吗?谢谢

bash stdout tee
  • 2 个回答
  • 384 Views
Martin Hope
Alec Gorge
Asked: 2010-04-16 19:19:18 +0800 CST

Windows:将 stdout 和 stderror 重定向为空

  • 51

我有一个正在运行的命令会产生大量输出,我想在不写入文件的情况下使输出静音。我使用以下内容将所有输出发送到文件:

command > out.txt 2>&1

...但我又不想任何文件输出:

command > /dev/null 2>&1

我以前command > /dev/null在我的 CentOS 机器上使用过,但我找不到适用于 windows 的类似东西。

windows windows-7 windows-command-prompt stdout
  • 2 个回答
  • 72166 Views

Sidebar

Stats

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

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve