LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 07-20-2010, 10:09 AM   #1
volumes
LQ Newbie
 
Registered: Jul 2010
Posts: 1

Rep: Reputation: 0
running process that sends email when returns 0


hi all,

I need a litle help, im trying to something like this:

a file or a process that is always running and pinging for example google.com.
returning 1 or 0, when returns 0 (that means have no response) do something else.
i already made the something else, basicly sends an email etc.

Can someone help me on this please ?

Best regards.
 
Old 07-20-2010, 11:13 AM   #2
timsgreen
LQ Newbie
 
Registered: Mar 2006
Posts: 14

Rep: Reputation: 2
How about something like this?

#!/bin/bash

PING_INTERVAL=3

send_email() {
echo "FAIL." | mail -s "ERROR" $1
}

while true; do
ping -w $PING_INTERVAL 4.2.2.100
if [ $? -ne 0 ]; then
send_email test@test.com
fi
done
 
  


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
[SOLVED] Email output of Cron command, sends email but no content? the182guy Linux - Newbie 4 05-28-2010 09:52 AM
How to configure an email server that sends email to hotmail with Fedora? acarri Linux - Server 5 03-10-2010 02:05 AM
Bash script to check if process is running and send email depam Linux - Newbie 2 04-08-2009 12:11 AM
POSTIX Sends Hostname in Email carlosinfl Linux - Server 6 01-15-2008 02:13 PM


All times are GMT -5. The time now is 05:42 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