Skip to content
Advertisement

Using crontab in linux to display a message everytime you open terminal?

I want to display message in terminal:

“Welcome!”

when someone opens the terminal

Advertisement

Answer

To print a message when opening a terminal (or logging in via ssh) you should use the message of the day (/etc/motd).

You could use cron to overwrite this file at specific times, and so users will see the current message when they log in:

00 1 * * * "/bin/echo 'Good morning' > /etc/motd"
00 12 * * * "/bin/echo 'Good afternoon' > /etc/motd"
00 17 * * * "/bin/echo 'Good evening' > /etc/motd" 
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement