MOTD 很少更新

Meg*_*tal 7 pam motd 13.10

我知道pam_motd在登录时更新 MOTD,但有时 MOTD 几天都没有更新,我很困惑可能是什么原因。我想添加uptimewho输出到 MOTD,从/etc/update-motd.d/脚本中正确调用它们,但如果向用户显示过时的信息,这似乎毫无意义。

update-motd手册页:

Executable  scripts  in  /etc/update-motd.d/* are executed by pam_motd(8) as
the root user at each login, and this information is concatenated in /var/run/motd.
The order of script execution is determined by the run-parts(8) --lsbsysinit option
(basically alphabetical order, with a few caveats).
Run Code Online (Sandbox Code Playgroud)

根据我的理解,每次登录时都应该更新 MOTD。但事实并非如此。而且我没有找到手动更新 MOTD 的脚本。我可以一个添加run-parts一行到cron,但我不认为这是解决这个问题的正确方法,因为这感觉就像一个黑客或替代方法。

我最后的希望是这样设置/etc/pam.d/login

# Prints the message of the day upon succesful login.
# (Replaces the `MOTD_FILE' option in login.defs)
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
#session    optional   pam_motd.so  motd=/run/motd.dynamic noupdate
session    optional   pam_motd.so  motd=/run/motd.dynamic
session    optional   pam_motd.so
Run Code Online (Sandbox Code Playgroud)

我认为删除noupdate会解决问题,但事实并非如此。

小智 4

我最近遇到了同样的问题。您还需要进行编辑/etc/pam.d/sshd以删除或注释掉那里的 noupdate。


Let*_*ety 4

update-motd是一个运行的简单脚本:

   run-parts --lsbsysinit /etc/update-motd.d 2>/dev/null
Run Code Online (Sandbox Code Playgroud)

根据运行部件手册:

   If  the  --lsbsysinit  option  is given, then the names must not end in
   .dpkg-old  or .dpkg-dist or .dpkg-new or .dpkg-tmp, and must belong  to
   one  or more of the following namespaces: the LANANA-assigned namespace
   (^[a-z0-9]+$);   the   LSB   hierarchical   and   reserved   namespaces
   (^_?([a-z0-9_.]+-)+[a-z0-9]+$);  and  the  Debian cron script namespace
   (^[a-zA-Z0-9_-]+$).
Run Code Online (Sandbox Code Playgroud)

因此,为了验证问题是否与update-motd文件名有关,请尝试:

   run-parts --test --lsbsysinit /etc/update-motd.d
Run Code Online (Sandbox Code Playgroud)

该命令打印将要运行的脚本的名称,但并不实际运行它们。