Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create script to send email when MySQl goes down

Status
Not open for further replies.

NickiNev1

Programmer
Sep 21, 2007
1
US
I tried this in php but it is giving me error of can't execute... Maybe if I do it in bash code it will work more smoothly???

This is the php script:
<?php
$link = mysql_connect('dev2.wiley.com', 'root', 'pass');
if (!$link) {
mail('name@place.com', 'Server Down', 'MySQL Server on dev Down');
die();
}
mysql_close($link);
?>

This is the error I get:
/opt/mysql/
bash-2.05# ./emailServerDown.php
bash: ./emailServerDown.php: Permission denied
bash-2.05# su mysql
$ ./emailServerDown.php
./emailServerDown.php: cannot execute
 
Hi

It is one line in a shell script :
Code:
mysql --user=root --password=pass --batch --execute= || echo 'MySQL Server on dev Down' | mail -s 'Server Down' 'name@place.com'
Although it is off-topic, did you tried with a shebang ? And of course, by giving execute permission to the file.
Code:
[red][b]#!/usr/bin/php[/b][/red]
<?php
$link = mysql_connect('dev2.wiley.com', 'root', 'pass');
if (!$link) {
   mail('name@place.com', 'Server Down', 'MySQL Server on dev Down');
   die();
}
mysql_close($link);
?>

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top