#!/bin/bash
# Obtain the server load
loadavg=`uptime |cut -d , -f 4|cut -d : -f 2`
thisloadavg=`echo $loadavg|awk -F \. '{print $1}'`
if [ "$thisloadavg" -eq "0.01" ]; then
ulimit -n 65536
service nginx restart
service php-fpm restart
fi
The error is:
./loadcheck.sh: line 7: [: 0.01: integer expression expected
I want to do a loadcheck shell script that can compare double instead of integer, as i want assured the load return is less than 0.01 which is 0.00 ,
If I use 0, even if the load is 0.05 , it will still execute the code.
in zsh you can simply use:
the double [[ construct allows extra tests and in zsh it allows floating point tests.