Aktionen
Preliminary note motd¶
You may find additional useful information atSetup 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.
add /usr/local/bin/gen_motd.sh¶
vim /usr/local/bin/gen_motd.sh
basic example:
#!/bin/bash # JKE 2011-05-14 # create /etc/motd # to be called by /etc/cron.d/gen_motd # echo -e " ******************************************************************* * xxyyy Janus Server * * ================== * * * * 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 * * and is advised that if such monitoring reveals possible * * evidence of criminal activity, system personel may provide the * * evidence from such monitoring to law enforcement officials. * * * ******************************************************************* * Version = `cat /etc/system-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
set shell-script being executeable
chmod +x /usr/local/bin/gen_motd.sh
add /etc/cron.d/gen_motd¶
vim /etc/cron.d/gen_motd
basic example:
# 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
Test¶
- recreate
motd
manually - login and check the output (you should see the motd)
/usr/local/bin/gen_motd.sh ssh user@localhost exit
- wait minimum 10 mins
- login once more, you should have an updated output
Von Jeremias Keihsler vor 4 Monaten aktualisiert · 2 Revisionen