LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-19-2012, 02:54 PM   #1
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Rep: Reputation: 17
Script for generate mail when server up


Hi,

I am looking script, when the server getting up.
Actually, my server is rebooting twice in day.
I am looking script, when the server is up.

Server is redhat 5.0.


Thanks.
 
Old 06-19-2012, 03:15 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Your post is kind of confusing, maybe a language barrier. Can you give a bit more detail and possibly some examples of what you are trying to do so we can give you a better answer?
 
Old 06-19-2012, 03:17 PM   #3
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
In your crontab, just add, for example:
Code:
@reboot echo "$(hostname)" | /usr/bin/mail -s "Server up" user@domin.com
 
2 members found this post helpful.
Old 06-19-2012, 03:26 PM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
macemoneta's post is more than likely your solution but I wanted to clarify what you were trying to accomplish before I gave you some code. Is that what you were looking for?
 
Old 06-19-2012, 03:34 PM   #5
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Original Poster
Rep: Reputation: 17
See, my server everyday reboot autmoatic.
so I want to make sricpt, which send me mail when the server is automatic come up after boot. so we can immmediate login and check the cause.

and above scipt, I couldnot understand how to add in crontab, can you please clarify.
 
Old 06-19-2012, 03:39 PM   #6
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Run the command 'crontab -e' as any user. Paste in the line above, and save the file.
 
Old 06-19-2012, 04:06 PM   #7
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Original Poster
Rep: Reputation: 17
can you please check the below command ...

# crontab -e

* * * * * /sbin/reboot echo "$(hostname)" | /usr/bin/mail -s "Server up" deepak_message@domin.com


is the above correct?
 
Old 06-19-2012, 04:19 PM   #8
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
No, the line must start with "@reboot" not "* * * * * /sbin/reboot". Check 'man crontab' for the syntax.
 
Old 06-19-2012, 04:56 PM   #9
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Original Poster
Rep: Reputation: 17
Thumbs up

Thanks macemoneta, this problem solved out.

A big thanks to you :-)
 
Old 06-19-2012, 06:47 PM   #10
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
I'm surprised you were able to access your server after adding this to your crontab
Code:
* * * * * /sbin/reboot echo "$(hostname)" | /usr/bin/mail -s "Server up" deepak_message@domin.com
Wouldn't that make the server reboot as soon as it started up?
 
Old 06-20-2012, 12:55 PM   #11
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Original Poster
Rep: Reputation: 17
No Kustom42, I made the crontab which was provided by macemoneta.
 
  


Reply



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
lftp remote server du -sh + mail script sappi Programming 3 07-28-2012 08:03 PM
generate script perl mail log not work puka Programming 4 05-31-2011 11:54 AM
[SOLVED] Need script to generate vouchers suse_nerd Programming 3 06-25-2010 10:13 AM
Generate Mail report kwtan Linux - Software 1 01-23-2006 04:41 AM
mail server generate so many refuse record. exper Linux - Software 3 02-21-2005 09:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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

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
Open Source Consulting | Domain Registration