Automating that regression testing

I’ve been testing drives lately. Mostly hard disks, but also one solid state drive. The test itself is automated, but manually started. That’s because it requires a reboot between each run.

That restricts testing time to certain hours of the day. I’d like to automate this.

Today I had what may be a clever solution:

  1. Use the @reboot feature of crontab(5) to start a script after reboot
  2. In that script, cd to a known directory
  3. Through a shell foreach loop, run the first file found in that directory
  4. At the end of the loop, move that file away
  5. reboot

Here’s the crontab entry:

@reboot root /home/dan/bin/benchmarks/reboot-script.sh

Here is the script mentioned above:

#!/bin/sh

logger $0

SCRIPTDIR="/home/dan/bin/benchmarks/reboot-scripts"
SCRIPTDIR_ARCHIVE="/home/dan/bin/benchmarks/reboot-scripts-archive"
SCRIPTS="`ls ${SCRIPTDIR}/* 2>/dev/null`"
for script in ${SCRIPTS}
do
  echo ${script}
  mv ${script} "${SCRIPTDIR_ARCHIVE}/"
  break
done

if [ "${SCRIPTS}X" != "X" ];
then
  echo reboot time
  logger rebooting now
  shutdown -r now
else
  logger now we are done, no rebooting this time.
  echo now we are done, no rebooting this time.
fi

How do you use it? Put all the scripts you want to run in SCRIPTDIR. Once per boot, the first script listed there will run. After running, it will be moved to SCRIPTDIR_ARCHIVE.

Should work fine.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top