Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 08-05-2008, 01:32 AM   #1
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 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
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

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,

Old 08-05-2008, 02:02 AM   #3
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
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: 61
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.


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 > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:27 PM.

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