I have this script. When I run it from the command line, it works fine. When I run it from cron, it only prints out half of the data
The results should look like this:
07/Feb/2012 11 0.5 07/Feb/2012 11 0.333333 07/Feb/2012 11 0.3
currently I'm getting just the date data when I run it from cron:
07/Feb/2012 11 07/Feb/2012 11 07/Feb/2012 11 07/Feb/2012 11
This is the script:
#!/bin/bash # PATH=/opt/someApp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/awk # Generate data and hour stamp date '+%d/%b/%Y %H' > /var/www/stats/datedata #Crank out and consider utlisation /usr/bin/./top -d 3 -n3 | /bin/./grep "Cpu" | awk '{ sum += $2/3 } END { print sum }' > /var/www/stats/usage_cpu # /usr/bin/./paste /var/www/stats/datedata /var/www/stats/usage_cpu >> /var/www/stats/thedata
This is my crontab entry: (I'm using /etc/crontab to set this up)
20 * * * * root /var/www/stats/./stats.sh