为了测量用户的总 CPU 时间,我使用了“utime”字段/proc/[pid]/stat
:
utime %lu Amount of time that this process has been scheduled in user
mode, measured in clock ticks (divide by
sysconf(_SC_CLK_TCK). This includes guest time, guest_time
(time spent running a virtual CPU, see below), so that
applications that are not aware of the guest time field do
not lose that time from their calculations.
Run Code Online (Sandbox Code Playgroud)
(来自man proc (5))
因此,我的“用户 utime”是utime
该用户正在运行的所有 PID的总和。
我希望这将为我提供该用户花费的 CPU 秒数的准确值。我在正确的轨道上吗?
我还不明白或考虑到的一些事情:
我目前设置$TERM
为xterm-256color
:
if [[ -n "$EMACS" ]]; then
export TERM=xterm-256color
alias emacs="emacsclient --no-wait"
export EDITOR="emacsclient --no-wait"
export VISUAL="emacsclient"
fi
Run Code Online (Sandbox Code Playgroud)
我曾经将它设置为eterm-color
,但问题是这种终端类型在我通过 SSH 登录的大多数机器上不可用。
.bashrc
Ubuntu 中的默认值检查TERM
变量是否以开头xterm-
,在这种情况下,它会尝试设置窗口标题:
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
Run Code Online (Sandbox Code Playgroud)
问题是\[\e]0;
一点。它应该由 xterm 兼容的终端模拟器解析,但 emacs (ansi-term) 不这样做。其结果是这样的终端:
0;user@host: ~user@host:~$
Run Code Online (Sandbox Code Playgroud)
readline
当输入的文本大于终端的宽度时,它也会使用,破坏一些应用程序。
因为eterm-color
在某些远程主机上不可用(而且我也无法安装它),将其设置为该值会使less
.
有什么我可以使用的技巧,例如大多数发行版附带的另一种终端类型,或者使 ansi-term 识别相关转义码并设置标题的黑客,或者只是丢弃它们?
我正在尝试在我的 NetBSD 5.1 机器上运行 CherryPy 应用程序。为了让它自动启动,我已将此行添加到我的/etc/rc.local
:
/bin/httpd &
Run Code Online (Sandbox Code Playgroud)
当我启动机器时,Webserver 启动的一些输出是可见的,就在Starting sshd.
消息之后。尽管如此,我无法连接到我的网络服务器。
我可以登录机器,当我输入 启动网络服务器时httpd
,一切正常。我究竟做错了什么?让我的程序在启动时启动的正确方法是什么?