-1

I have crontab and a simple bash script that sends me emails every often containing PHP, NGINX, MYSQL errors from their log files. This is a simplified example.

#/home/user/status.sh
[email protected]
  PHP_ERROR=`tail -5 /var/log/php-fpm/error.log`
  NGINX_ERROR=`tail -5 /var/log/nginx/error.log`
  MYSQL_ERROR=`tail /var/log/mysqld.log`
  DISK_SPACE=`df -h`
  echo "

Today's, server report::
==================================
    DISK_SPACE: $DISK_SPACE
 ---------------------------------
    MEMORY_USAGE: $MEMORY_USAGE
-----------------------------------
    NGINX ERROR: $NGINX_ERROR
-----------------------------------
    PHP ERRORS: $PHP_ERROR
------------------------------------
    MYSQL_ERRORS: $MYSQL_ERROR
-------------------------------------
 " | mail -s "Server reports" $EMAIL

I know this is a very basic usage, but as you can see, I am trying to separate the errors, but not of the html tags including \n are working.

So, my question is, is it possible to use HTML tags to format the text, if not .. then what are the alternatives.

1 Answer 1

0

You can use whatever formatting your mail client can read. To encode your message better, use the <<EOF syntax:

#/home/user/status.sh
[email protected]
PHP_ERROR=`tail -5 /var/log/php-fpm/error.log`
NGINX_ERROR=`tail -5 /var/log/nginx/error.log`
MYSQL_ERROR=`tail /var/log/mysqld.log`
DISK_SPACE=`df -h`
mail -s "Server reports" $EMAIL <<EOF
Today's, server report::
==================================
    DISK_SPACE:   $DISK_SPACE
----------------------------------
    MEMORY_USAGE: $MEMORY_USAGE
----------------------------------
    NGINX ERROR:  $NGINX_ERROR
----------------------------------
    PHP ERRORS:   $PHP_ERROR
----------------------------------
    MYSQL_ERRORS: $MYSQL_ERROR
----------------------------------
EOF
3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .