LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-05-2008, 01:32 AM   #1
Swakoo
Member
 
Registered: Apr 2005
Distribution: Red Hat / Fedora / CentOS
Posts: 508

Rep: Reputation: 30
Getting cron result mailed back


hi guys,

i am testing to cron my servers to reboot monthly by calling /sbin/reboot
but is it possible to get cron to mail me when it actually does that?

i tried mailto=my@email.com but nothing happen, but the server rebooted though..

is the mailto meant for this purpose? or so I read, it seems like it is...
 
Old 08-05-2008, 01:44 AM   #2
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

Quick and dirty if you want to get email no matter what distro you're on. If you're cron entry is, let's say:

59 23 * * * /usr/sbin/reboot

just change it to this:

59 23 * * * /usr/sbin/reboot 2>&1|/usr/lib/sendmail you@yourdomain.com

Now as for the reboot notification, in and of itself, you may still have issues since the machine is shutting down. If you could use a program like shutdown with the -g flag to set a grace period, like 60 seconds, the reboot would have time to send out a mail before it potentially cripples the mailing subsystem by sending it a TERM signal at reboot

Best wishes,

Mike
 
Old 08-05-2008, 02:02 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,232

Rep: Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023
I'd put both in a small shell script, calling the sendmail first, so it won't reboot until it's already sent the email.
You can also add a send email call to /etc/rc.local, which is the last thing called at boot time. This will confirm the system is back up.
 
Old 08-05-2008, 03:21 AM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
You may need a little delay in between your sendmail and reboot, if you want to ensure that the mail has left the mail queue and arrived at its destination.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron will not start back up after stop RaelOM Linux - Software 3 12-15-2006 12:53 PM
Alrighty, I'm back. Again. Cron Job ... sdebiasio Linux - Newbie 9 08-05-2004 08:02 AM
getting updated threads e-mailed selassie irie Linux - Newbie 2 07-04-2004 11:08 AM
Cron chaning back hosts.deny! filiphw Linux - Security 6 12-30-2003 02:09 PM
Spammer gets junk mailed acid_kewpie General 8 01-04-2003 10:03 AM


All times are GMT -5. The time now is 09:18 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration