什么创建了 /tmp/fileRandomName 日志文件以及如何禁用它或重定向到 /dev/null?

什么创建了 /tmp/fileRandomName 日志文件以及如何禁用它或重定向到 /dev/null?

每次用户登录时都会/tmp创建类似.xsession-errors或其他日志的文件。例如,当前名称是/tmp/filercrEUk。我没有看到它们在注销后被删除,而且我不需要它们。

示例head内容

Xsession: X session started for user at п'ятниця, 5 липня 2019 14:34:41 +0300
localuser:user being added to access control list
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
startkde: Starting up...
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/libexec/kf5/klauncher'
kdeinit5: Launched KLauncher, pid = 498, result = 0
kdeinit5: opened connection to :0
kdeinit5: preparing to launch 'libkdeinit5_kded5'
kdeinit5: Launched KDED, pid = 503 result = 0

答案1

这些文件由...制作/etc/X11/Xsession

ERRFILE=$HOME/.xsession-errors

# attempt to create an error file; abort if we cannot
if (umask 077 && touch "$ERRFILE") 2> /dev/null && [ -w "$ERRFILE" ] &&
  [ ! -L "$ERRFILE" ]; then
  chmod 600 "$ERRFILE"
elif ERRFILE=$(tempfile 2> /dev/null); then
  if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
    message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \
             "\"$ERRFILE\"; look for session log/errors in" \
             "\"$TMPDIR/xsession-$USER\"."
  fi
else
  errormsg "unable to create X session log/error file; aborting."
fi

唯一的办法就是修补它。它特别包括检查 ~/.xsession-errors 是否是符号链接。我做了一个修补添加了对环境变量的检查$NOXSESSIONERRORS。您可以在 中定义它/etc/environment

相关内容