Skip to content

Instantly share code, notes, and snippets.

@nickvanw
Last active August 29, 2015 13:57
Show Gist options
  • Save nickvanw/9863660 to your computer and use it in GitHub Desktop.
Save nickvanw/9863660 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Save this script somewhere (chmod it 777) and add this to cron:
# 0 */2 * * * cd ~; dd.sh
#
# There are some configuration variables to change below these comments
#
# You'll want to set where the dd command prints to, as well as what command it runs
#
BASH_CMD="dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync"
CLEANUP="rm test"
CURRENT_RESULT_DATA="/tmp/dd_output.txt"
HISTORIC_DATA="/tmp/dd_historic.txt"
# RUN THA SCRIPT
DD_OUTPUT=$($BASH_CMD 2>&1)
DATE_STR=$(date)
echo $DATE_STR > $CURRENT_RESULT_DATA
echo $'\n' >> $CURRENT_RESULT_DATA
echo $DATE_STR >> $HISTORIC_DATA
echo $'\n' >> $HISTORIC_DATA
echo $DD_OUTPUT >> $CURRENT_RESULT_DATA
echo $DD_OUTPUT >> $HISTORIC_DATA
echo $'\n' >> $CURRENT_RESULT_DATA
echo $'\n' >> $HISTORIC_DATA
$($CLEANUP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment