Q:需求每天将磁盘使用情况写入到以日期命名的log文件内,日期格式xxxx-xx-xx,后缀名.log。

A:脚本如下

#!/bin/bash

d=`date +%F`
file_name=$d.log
df -h > /tmp/$file_name