Re: How do I send a email to all users on server?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



fedora-list@xxxxxxxxxxxxxxxxxxxxxx wrote:
> On Mon, February 19, 2007 13:56, Bazooka Joe wrote:
>> I want to notify my users of downtime... I have not been able to find
>> any way to send an email to all users on server.
>>
>> any idea how that is done?
> 
> Lotsa ways to do it.  You could create an alias with all the names, for
> instance, and mail to that.  If they're in /etc/passwd, then
> 
> cat /etc/passwd|cut -d: -f1|while
> read user
> do
>   mail -s "Downtime Scheduled" $user < message.txt
> done
> 
> would do it (put your message in message.txt).  You'd also send mail to
> the non-user users like daemon, but you'd cover everybody.  If you're
> using NIS, then "ypcat passwd" instead of "cat /etc/passwd".
> 
You could use something like:

getent passwd | awk -F: '{if ( $3 >= 500 ) print $1}' | while

in place of the cat /etc/passwd line. The awk section give you users
with UID 500 or greater. You may have to change it to 100, depending
on the UID of the first non-system user. You could also test the
home directory to see if it is /home/<something>.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux