[go: up one dir, main page]

0% found this document useful (0 votes)
3 views1 page

Monitor Mysql Error

This script gets the MySQL error log file path, constructs a grep command to search for errors from the current date in that log file, and executes the command to display any matching errors.

Uploaded by

pavanlondon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Monitor Mysql Error

This script gets the MySQL error log file path, constructs a grep command to search for errors from the current date in that log file, and executes the command to display any matching errors.

Uploaded by

pavanlondon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#!

/bin/bash

# Get the MySQL error log file path


log_error_path=$(mysql -u your_username -p'your_password' -e "show variables like
'log_error';" | grep -oP '\s+\K\S+$')

# Get today's date in the format YYYY-MM-DD


today_date=$(date +'%Y-%m-%d')

# Construct the command to grep for errors in the log file


grep_command="grep \"$today_date\" $log_error_path | grep \"ERROR\""

# Execute the command and display the errors


eval $grep_command

You might also like