dd.sh

Discussion in 'Server Stuff' started by Mun, May 23, 2014.

  1. Mun

    Mun Administrator

    This script combined with a cronjob will run a dd test every few (define period of time) and copy it to your /var/www folder so you can have an easy way to see past DD tests. We suggest you only use this every few hours (12) and no more. This script isn't suggested for VPSs as you may get banned for I/O abuse.

    Main script:
    Code:
    #!/bin/bash
    #This program is free software: you can redistribute it and/or modify
    #it under the terms of the GNU General Public License as published by
    #the Free Software Foundation, either version 3 of the License, or
    #(at your option) any later version.
    #
    #This program is distributed in the hope that it will be useful,
    #but WITHOUT ANY WARRANTY; without even the implied warranty of
    #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #GNU General Public License for more details.
    #
    #You should have received a copy of the GNU General Public License
    #along with this program.  If not, see <http://www.gnu.org/licenses/>.
    #
    # I kindly ask that you however do not post this code else where for the
    # purpose of showing others, and instead I ask that you link to this post.
    # https://www.qwdsa.com/discuss/viewtopic.php?id=23
    
    DDSTO=/var/www/dd.txt
    DDHIS=/var/www/dd_historical.txt
    TEMPSTO=/tmp/dd.txt
    
    cat $DDSTO >> $DDHIS  ## this creates a copy of your past (most recent dd) into the dd_historical.txt file
    echo -e '\n'>> $DDHIS  ## this echos a new line on your dd_histoical so you don't have overlapping
    echo ''> $DDSTO  ## this clears your dd.txt so that dd command can run properly
    date >> $DDSTO  ## this echos the date so you can see when the dd command was run
    echo ''> $TEMPSTO  ## this clears out your temp .txt file
    dd if=/dev/zero of=test bs=64k count=1k conv=fdatasync 2> $TEMPSTO; unlink test  ## this runs the default dd command and posts it to the temp .txt file
    cat $TEMPSTO >> $DDSTO  ## this copies the temp file to the main file.
    To set up with crontab simply run:
    Code:
    crontab -e
    
    and add at the bottom of the file:
    Code:
    0 */12 * * * cd /root/ && ./dd.sh
    
    this will run every 12 hours, if you want it at a different interval simply change the cron to something else.


    As a side note, I do not suggest using this on a virtual server as you are likely to get banned, note GVH:
    [​IMG]


    Mun
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice