nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Automated email

This is a discussion on Automated email within the CentOS / RHEL / Fedora forums, part of the Linux Distribution category; hello all, i want to run a small script which supposed to send an email when the server 1)started 2)shutdown ...


Go Back   nixCraft Linux Forum > Linux Distribution > CentOS / RHEL / Fedora

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 03-04-2008, 05:44 PM
Junior Member
User
 
Join Date: Feb 2008
My distro: CentOS
Posts: 2
Rep Power: 0
srinivasantarvedi is on a distinguished road
Default Automated email

hello all,
i want to run a small script which supposed to send an email when the server
1)started
2)shutdown
3)reboot

my OS :cenOS

i did following:
1)created my script and added executive permissions and copied to /etc/init.d directory
2)created symbolic links in /etc/rc5.d as K90myscript and S90myscript
when i created like above it was working fine and i am getting a mail to my email id
successfully.

i want to do the following:

1)when my system reboots i need an email alert (script should execute)
2)when my system shutdowns i need an email alert (script should execute)
for the above things i created with the above script two symbolic links to
rc6.d(for reboot purpose) and rc0.d(for shutdown purpose) and given
the links with S(start script) .

and also what i observed is that the sendmail service is stopped(K30sendmail) much before this S script(S90 script) in the above rc6.d and rc0.d directories. i think that is the only reason i am not getting the mails in the case of reboot and shutdown levels '

then how can i do it??

thanks and regards
srinivas antarvedi
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-05-2008, 01:00 AM
agn agn is offline
Member
User
 
Join Date: Feb 2008
My distro: OpenBSD/FreeBSD/Debian/Fedora/RHEL
Posts: 69
Rep Power: 1
agn is on a distinguished road
Default

Create symlinks in rc0.d and rc6.d with a name like K<number-less-than-30>script_name. The K doesn't necessarily mean that a service gets killed. Its means that the script gets executed with a 'stop' argument. You don't have to use the argument passed to it.
Reply With Quote
  #3 (permalink)  
Old 03-05-2008, 10:31 AM
Junior Member
User
 
Join Date: Feb 2008
My distro: CentOS
Posts: 2
Rep Power: 0
srinivasantarvedi is on a distinguished road
Default Automated email

Hello agn(sorry i dunno your name),
Thanks for the reply..
and i tried as you described but its not working

i did like this
1)kept my scirpt in /etc/init.d/ dierectory
2)created symbolic link ln -s /etc/init.d/<myscript> /etc/rc0.d/K01<myscript>
3)created symbolic link ln -s /etc/init.d/<myscript> /etc/rc6.d/K01<myscript>

I have intentionally given the seqeunce name as K01 to avoid any possible chances
of stopping the dependent services .

still i am not getting the script worked.

only script i put in /etc/rc5.d/<myscript> seems to work on reboot

can u explain how to do it

thanks for the help
regards
srinivas antarvedi
Reply With Quote
  #4 (permalink)  
Old 03-05-2008, 12:44 PM
agn agn is offline
Member
User
 
Join Date: Feb 2008
My distro: OpenBSD/FreeBSD/Debian/Fedora/RHEL
Posts: 69
Rep Power: 1
agn is on a distinguished road
Default

My guess is that the mail gets sent but the systems gets shutdown/rebooted before it leaves the system. Add 'sleep 30' to the end of the script and see if you get the mail. Also check your logs.
Reply With Quote
  #5 (permalink)  
Old 04-14-2008, 08:26 PM
Junior Member
User
 
Join Date: Apr 2008
My distro: Debian
Posts: 1
Rep Power: 0
drsinger111 is on a distinguished road
Default

if you find out more about this, please post it here, i would be interested also in how to do this...


thanks in advance


D
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Email Server, suggestions? s1lent Mail Servers 7 03-09-2008 10:46 AM
why can't forward large email attachment? khaosregion Mail Servers 4 10-26-2007 12:49 AM
need help to write automated server monitering script vishal Titre Shell scripting 1 07-15-2006 02:35 AM
required linux email help vaishalichitale Linux software 4 06-20-2006 02:20 PM
How to forward an email to other account tom Getting started tutorials 2 09-25-2005 09:58 PM


All times are GMT +5.5. The time now is 03:18 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36