简体   繁体   English

每次打开终端时在Linux中使用crontab显示消息吗?

[英]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 当有人打开终端时

To print a message when opening a terminal (or logging in via ssh) you should use the message of the day (/etc/motd). 要在打开终端(或通过ssh登录)时打印消息,应使用当天的消息(/ 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: 您可以使用cron在特定时间覆盖此文件,因此用户登录时将看到当前消息:

00 1 * * * "/bin/echo 'Good morning' > /etc/motd"
00 12 * * * "/bin/echo 'Good afternoon' > /etc/motd"
00 17 * * * "/bin/echo 'Good evening' > /etc/motd" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM