# man > update-motd(5)

[_update-motd_(5)](https://www.chedong.com/phpMan.php/man/update-motd/5/markdown)                           File Formats Manual                          [_update-motd_(5)](https://www.chedong.com/phpMan.php/man/update-motd/5/markdown)

## NAME
       update-motd - dynamic MOTD generation


## SYNOPSIS
       **/etc/update-motd.d/***


## DESCRIPTION
       UNIX/Linux  system  administrators often communicate important information to console and re‐
       mote users by maintaining text in the file _/etc/motd_, which is displayed by  the  [**pam_motd**(8)](https://www.chedong.com/phpMan.php/man/pammotd/8/markdown)
       module on interactive shell logins.

       Traditionally, this file is static text, typically installed by the distribution and only up‐
       dated  on release upgrades, or overwritten by the local administrator with pertinent informa‐
       tion.

       Ubuntu introduced the **update-motd **framework, by which the [**motd**(5)](https://www.chedong.com/phpMan.php/man/motd/5/markdown)  is  dynamically  assembled
       from a collection of scripts at login.

       Executable  scripts  in  _/etc/update-motd.d/*_ are executed by [**pam_motd**(8)](https://www.chedong.com/phpMan.php/man/pammotd/8/markdown) as the root user at
       each login, and this information is concatenated in _/run/motd.dynamic_.  The order  of  script
       execution  is  determined by the [**run-parts**(8)](https://www.chedong.com/phpMan.php/man/run-parts/8/markdown) --lsbsysinit option (basically alphabetical or‐
       der, with a few caveats).

       On Ubuntu systems, _/etc/motd_ is typically a symbolic link to _/run/motd.dynamic_.


## BEST PRACTICES
       MOTD fragments must be scripts in _/etc/update-motd.d_, must be executable, and must  emit  in‐
       formation on standard out.

       Scripts should be named named NN-xxxxxx where NN is a two digit number indicating their posi‐
       tion in the MOTD, and xxxxxx is an appropriate name for the script.

       Scripts must not have filename extensions, per [**run-parts**(8)](https://www.chedong.com/phpMan.php/man/run-parts/8/markdown) --lsbsysinit instructions.

       Packages  should  add scripts directly into _/etc/update-motd.d_, rather than symlinks to other
       scripts, such that administrators can modify or remove these scripts and  upgrades  will  not
       wipe  the  local changes.  Consider using a simple shell script that simply calls **exec **on the
       external utility.

       Long running operations (such as network calls) or resource intensive  scripts  should  cache
       output, and only update that output if it is deemed expired.  For instance:

         /etc/update-motd.d/50-news
         #!/bin/sh
         out=/run/foo
         script="w3m -dump <http://news.google.com/>"
         if [ -f "$out" ]; then
           # Output exists, print it
           echo
           cat "$out"
           # See if it's expired, and background update
           lastrun=$(stat -c %Y "$out") || lastrun=0
           expiration=$(expr $lastrun + 86400)
           if [ $(date +%s) -ge $expiration ]; then
             $script > "$out" &
           fi
         else
           # No cache at all, so update in the background
           $script > "$out" &
         fi

       Scripts  should  emit  a blank line before output, and end with a newline character.  For in‐
       stance:

         /etc/update-motd/05-lsb-release
         #!/bin/sh
         echo
         lsb-release -a


## FILES
       _/etc/motd_, _/run/motd.dynamic_, _/etc/update-motd.d_



## SEE ALSO
       [**motd**(5)](https://www.chedong.com/phpMan.php/man/motd/5/markdown), [**pam_motd**(8)](https://www.chedong.com/phpMan.php/man/pammotd/8/markdown), [**run-parts**(8)](https://www.chedong.com/phpMan.php/man/run-parts/8/markdown)


## AUTHOR
       This manpage and the update-motd framework was written by Dustin  Kirkland  <kirkland@canoni‐
       cal.com> for Ubuntu systems (but may be used by others).  Permission is granted to copy, dis‐
       tribute  and/or  modify this document under the terms of the GNU General Public License, Ver‐
       sion 3 published by the Free Software Foundation.

       On Debian systems, the complete text of the GNU  General  Public  License  can  be  found  in
       /usr/share/common-licenses/GPL.

update-motd                                 13 April 2010                             [_update-motd_(5)](https://www.chedong.com/phpMan.php/man/update-motd/5/markdown)
