Recent Changes - Search:

Softwares

.

GeneratingSystemStatsUsingLinuxCommandForLaterView

    vi  /root/stats.sh


  #!/bin/sh
  # Collect random system data
  TEMPFILE="/var/log/$(hostname)"
  echo "|----------System stat log file----------|" >> $TEMPFILE
  echo "|--------------DATE----------------------|" >> $TEMPFILE
  /bin/date >> $TEMPFILE
  echo "" >> $TEMPFILE
  echo "|--------------Memory Usage in MB--------|" >> $TEMPFILE
  echo "" >> $TEMPFILE
  /usr/bin/vmstat -m >> $TEMPFILE
  echo "" >> $TEMPFILE
  echo "| Top 10 memory-consuming processes: |" >> $TEMPFILE
  echo "" >> $TEMPFILE
  ps aux --no-headers| sort -rn +3 | head >> $TEMPFILE
  echo "" >> $TEMPFILE
  echo "                            |++++++END OF SCAN ++++++|" >> $TEMPFILE
  echo "" >> $TEMPFILE
  ## End
  • Change permission
  chmod +x  /root/stats.sh
  • Add to cron.
  % crontab -e -u root

  * * * * * /bin/sh  /root/stats.sh >/dev/null 2>&1
Edit - History - Print - Recent Changes - Search
Page last modified on March 20, 2007, at 01:23 PM