工作过程中,为了监控状态,经常要不断地重复执行某个命令,因此写了个脚本来简化操作
#! /bin/bash# filename:redo.sh#usage: redo.sh [-d delaytime] [-c count] command#默认间隔时间为15s,无限循环执行delay=15count=-1while getopts d:c: OPTIONdo case $OPTION in d) delay=$OPTARG ;; c) count=$OPTARG ;; esacdoneshift $(expr $OPTIND - 1)i=0while [ $i -ne $count ]do clear echo "command:" $@ echo "count:" $i echo "delay:" $delay eval $@ i=$(expr $i + 1) sleep $delaydone