LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-13-2011, 02:45 PM   #1
smithy2010
Member
 
Registered: May 2010
Location: UK
Distribution: OpenSuse 64 bit
Posts: 45

Rep: Reputation: 15
Talking emil me on boot


Hello all,

I want to setup my Fedora 15 computer to email me every time it boots and I want computer to email me before a user logs in. Can you advice how I can achieve this?

Thank you in advance

Smithy
 
Old 06-13-2011, 02:53 PM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

You could add a command to mail you in the /etc/rc.local file, which is the last init file executed when booted. For the users, you could add something similar to the .bashrc or .bash_profile file in their home directory but you'll have to make it immutable or they will be able to change it. Those are only some options, I'm sure there will be more posted shortly.

In either case, you'll have to make sure that your server is set up to deliver mail and that it's functioning correctly (test it).

Kind regards,

Eric
 
Old 06-13-2011, 03:24 PM   #3
flakblas
Member
 
Registered: Jun 2009
Location: Maryland
Distribution: Fedora, CentOS, RHEL, Ubuntu
Posts: 41

Rep: Reputation: 3
I would use the rc.local method for when the system boots but I wouldn't use the bashrc method for when users login as this is extremely easy to circumvent. I'd write a script that scrapes lastlog or something then runs a command like:
Code:
mail -s "$username logged in - $(date)" youremail@domain.tld </dev/null
 
Old 06-14-2011, 01:29 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
You can add the email cmd to /etc/profile (for 2nd qn) as this is run as user logs in, but before their personal bash_profile/bashrc files are called and (should be) only accessible by root.
 
Old 06-14-2011, 07:40 AM   #5
flakblas
Member
 
Registered: Jun 2009
Location: Maryland
Distribution: Fedora, CentOS, RHEL, Ubuntu
Posts: 41

Rep: Reputation: 3
Quote:
Originally Posted by chrism01 View Post
You can add the email cmd to /etc/profile (for 2nd qn) as this is run as user logs in, but before their personal bash_profile/bashrc files are called and (should be) only accessible by root.
Ah good call.
 
Old 06-14-2011, 01:21 PM   #6
smithy2010
Member
 
Registered: May 2010
Location: UK
Distribution: OpenSuse 64 bit
Posts: 45

Original Poster
Rep: Reputation: 15
Thank you all, I'll try what you suggested and come back if I have any questions.

Cheers

Smithy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Boot Camp (fixing boot loaders, learning your way around boot & chainloaders) Siljrath Linux - General 8 01-20-2015 12:00 PM
Is it better on dual boot,trible boot,quad boot rather than virtual machines? pleasehelpme Linux - Newbie 3 12-15-2007 01:04 PM
When I boot my comp. (dual boot sys-Suse 10.1 & Win XP) the first boot stalls. philip niedermeyer Linux - Desktop 5 11-13-2006 07:04 PM
Kind souls: help getting Mandriva install 2 boot? edit boot.ini/grub /boot device or NoMoreReinstallMS Linux - Newbie 1 08-09-2006 05:34 AM
GRUB: How to boot WinXP (NTLDR, NTDETECT.COM & BOOT.INI) from boot partition (EXT2) ? Rayen16 Linux - Software 1 05-25-2006 01:09 PM


All times are GMT -5. The time now is 04:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration