Open cfanbo opened 10 months ago
https://blog.haohtml.com/archives/11827
date +%Y%m%d
date +%H:%M:%S
ifconfig bge0 | grep status | awk '{print $2}'
ifconfig bge0 | awk '/status/{print $2}'
https://blog.haohtml.com/archives/11827
/bin/bash log_file=
date +%Y%m%d
log_file=$log_file".log" check_date=date +%H:%M:%S
#status=ifconfig bge0 | grep status | awk '{print $2}'
status=ifconfig bge0 | awk '/status/{print $2}'
if [ $status != 'active' ]; then status='down' ifconfig bge0 up else echo 'ok' fi check_date=${check_date}" =========== "${status} echo $check_date >> $log_file 另一处写法,其实一样的:!/bin/bash log_file="$(date +%Y%m%d).log" status=$(ifconfig bge0 | awk '/status/{print $2}') if [ "X${status}" != "Xactive" ]; then ifconfig bge0 up fi echo "$(date +%H:%M:%S) ===== ${status}" >> $log_file