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/

Here is the script mentioned above:


logger $0

SCRIPTS="`ls ${SCRIPTDIR}/* 2>/dev/null`"
for script in ${SCRIPTS}
  echo ${script}
  mv ${script} "${SCRIPTDIR_ARCHIVE}/"

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

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 Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top