Shell programming --- write the query information into the file of the day

Write hard disk usage information and query Mysql process related information into the new day's file

  • > Write
  • >> add

For the date format, please see this article: https://blog.csdn.net/qq_43288259/article/details/114834574

#!/bin/bash
filename=`date +%F`
c=`df -h`
d=`ps -aux|grep -o 'mysql.*'`
echo "$c" >/root/$filename.log
echo "$d" >>/root/$filename.log

Check the log file of the day's date under root
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43288259/article/details/114836594