I wrote a simple bash script that checks the load average values using 'uptime' every 5 minutes and writes a result to the text file. Everything is OK except one thing: every day from 12:00 to 13:00 I see text value 'average' instead of regular integer values.
How should I interpreter the 'average' as a result of 'uptime' command? And if I run 'uptime' from the command line everything is OK - I see regular integer values.
The source code below:
#!/bin/bash
sCurrentUptime="$(uptime | awk '{print $10}')"
iLength="${#sCurrentUptime}"
sUptime="${sCurrentUptime:0:iLength-1}"
iUptime=${sUptime/.*}
now="$(date)"
echo $now';'$iUptime
And here are the outputs (last collumns contains load average value):
Thu Apr 17 08:40:01 MSK 2014;0
Thu Apr 17 09:00:01 MSK 2014;2
Thu Apr 17 09:20:02 MSK 2014;3
Thu Apr 17 09:40:02 MSK 2014;3
Thu Apr 17 10:00:01 MSK 2014;2
Thu Apr 17 10:20:01 MSK 2014;3
Thu Apr 17 10:40:01 MSK 2014;1
Thu Apr 17 11:00:02 MSK 2014;2
Thu Apr 17 11:20:01 MSK 2014;3
Thu Apr 17 11:40:01 MSK 2014;2
Thu Apr 17 12:00:02 MSK 2014;3
Thu Apr 17 12:20:02 MSK 2014;average
Thu Apr 17 12:40:01 MSK 2014;average
Thu Apr 17 13:00:01 MSK 2014;average
Thu Apr 17 13:20:01 MSK 2014;3
Thu Apr 17 13:40:01 MSK 2014;1
Thu Apr 17 14:00:01 MSK 2014;2
Thu Apr 17 14:20:01 MSK 2014;3
Thu Apr 17 14:40:01 MSK 2014;2
Thu Apr 17 15:00:01 MSK 2014;2
Thu Apr 17 15:20:01 MSK 2014;3
Thu Apr 17 15:40:01 MSK 2014;1
uptime
. – gniourf_gniourf Apr 27 '14 at 14:56