Setup motd » Historie » Revision 2
Revision 1 (Jeremias Keihsler, 12.01.2017 11:41) → Revision 2/3 (Jeremias Keihsler, 12.01.2017 11:43)
h1. Preliminary note motd You may find additional useful information at * http://wiki.centos.org/TipsAndTricks/BannerFiles h2. h1. Setup motd The @/etc/motd@ is a file on Unix-like systems that contains a "message of the day". This file is just static text, therefore we recreate this file every 10 mins with updated information. I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. h2. add /usr/local/bin/gen_motd.sh <pre><code class="bash"> vim /usr/local/bin/gen_motd.sh </code></pre> basic example: <pre> #!/bin/bash # JKE 2011-05-14 # create /etc/motd # to be called by /etc/cron.d/gen_motd # echo -e " ******************************************************************* * xxyyy Janus Server * * ================== ======h1. * * * * This system is for the use of authorized users only. Usage of * * this system will be monitored and recorded by system personnel. * * * * Anyone using this system expressly consents to such monitoring * monitoring* * and is advised that if such monitoring reveals possible * * evidence of criminal activity, system personel may provide the * the* * evidence from such monitoring to law enforcement officials. * * * ******************************************************************* * Version = `cat /etc/centos-release` * Kernel = `uname -r` * Uptime = `uptime | sed 's/.*up \([^,]*\), .*/\1/'` * Mem /free = `cat /proc/meminfo | grep MemTotal | awk {'print $2'}` kB / `cat /proc/meminfo | grep MemFree | awk {'print $2'}` kB * Swap/free = `cat /proc/meminfo | grep SwapTotal | awk {'print $2'}` kB / `cat /proc/meminfo | grep SwapFree | awk {'print $2'}` kB * last updt = `date` ******************************************************************* " > /etc/motd </pre> set shell-script being executeable <pre><code class="bash"> chmod +x /usr/local/bin/gen_motd.sh </code></pre> h2. add /etc/cron.d/gen_motd <pre><code class="bash"> vim /etc/cron.d/gen_motd </code></pre> basic example: <pre> # JKE 2011-05-14 # # min hr dom month dow user command # - - - - - # | | | | | # | | | | +-day of week (0-7) sunday=0 or 7 # | | | +---------month (1-12) # | | +-----------------day of month (1-31) # | +-------------------------hour (0-23) # +-------------------------------------------------min (0-59) # 5,15,25,35,45,55 * * * * root /usr/local/bin/gen_motd.sh </pre> h2. Test h1. Check motd * recreate @motd@ manually * login and check the output (you should see the motd) <pre><code class="bash"> /usr/local/bin/gen_motd.sh ssh root@localhost exit </code></pre> * wait minimum 10 mins * login once more, you should have an updated output