Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking for a command similar to wall but will deliver a message to users currently sshed in and if they are not logged in will display upon their next ssh login( but only once ). Context is that I may( not guaranteed ) have a network outage but not everyone on the machine(s) will have gotten the maintenance email and I would rather forward the email to all the users of the machine(s). Not looking to put a message in /etc/motd since that will put up the message upon every login.

share|improve this question
3  
What is the problem with getting this message multiple times upon login? Just remove it after the outage is done or definitely not necessary. –  SvW Mar 14 '13 at 12:30
1  
It's annoying to get spammed with countless messages when it's always the same thing, I guess that's the only reason. –  gparent Mar 14 '13 at 16:03
    
That is pretty much the reason, I know I open up two or three shell sessions and quite a number of users login on somewhat spotty internet connections so getting hit with the same message a couple dozen times a day gets irritating quickly. –  VincentAlpha Mar 14 '13 at 17:41

2 Answers 2

up vote 3 down vote accepted

There's a standard way of doing this: news. In olden times this was a standard command, but these days it's a bit crusty and has to be installed manually. The Debian/Ubuntu package you want is sysnews.

To use it,

  • create a file called something like /var/lib/sysnews/login-message containing your message
  • add news to /etc/profile (or equivalent for your users' shell)

When your users log in, they'll see the message the first time, but then .news_time is created in their home directory, and they'll only see news items that have been modified since the timestamp of that file.

share|improve this answer
    
Sounds like exactly what I am looking for, just need to find a package for CentOS then. Cheers! –  VincentAlpha Mar 14 '13 at 17:44

Do you have a global /etc/profile that you could do this from? Won't catch everyone and their weird shell of the day, but basically

if [ ! -e "$HOME/.saw-the-message" ];
   echo "The system will go down tomorrow, but I will never tell you again!"
   touch $HOME/.saw-the-message
fi

Problems:

  • you'll have to clean up the lock files afterwards
  • misses some people who use $weird_shell
share|improve this answer
    
Dont you mean if [ ! -e "$HOME/.saw-the-message" ]; ? –  user160910 Mar 14 '13 at 13:01
    
Erm, I do. Thanks. –  themel Mar 14 '13 at 16:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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