1

Every week there's a new work log/to-do list at work. There's a todo script which can be used to extract my own to-do items from that. Currently this is called in ~/.bash_aliases_local, which is sourced from ~/.bash_aliases. Rather than parsing the log every time I start another shell, I'd like to use the standard MOTD (message of the day) functionality. This would involve updating a static file with the to-do list on a weekly basis:

@weekly update-motd

The resulting static text file should be printed every time I start an interactive Bash shell. What's the standard way to do this?

5

If you want to have the message displayed every time you open up a new terminal (under an X session), then motd is not the right place. It is executed by the login program - this happens when you log in on a real tty (or via ssh for example).

For terminal sessions, I believe the only universal way is to run cat somefile at the end of your shell's startup file: either personal (i.e. ~/.bashrc ~/.zshrc etc.) or global (under /etc - see your shell's manpage for details). Generally, I'm afraid there isn't a "standard" way of doing this in case of terminal emulator sessions.

  • Seems that .bashrc is not right place too. There are ~/.bash_login and ~/.bash_logout files . They're much better for OP purpose. – rush Apr 12 '12 at 13:52
  • 4
    @Rush .bash_login only read if bash is a login shell (and even then most people have .bash_profile instead). It would be of no help here, as the question is about all interactive shells. .bashrc is exactly the right file for this purpose. – Gilles Apr 12 '12 at 23:31
1
  1. create /etc/update-motd.d/
  2. place the script there, with format 00script (no .sh)

it will show up in every login

all details are here

https://ownyourbits.com/2017/04/05/customize-your-motd-login-message-in-debian-and-ubuntu/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.