#!/bin/bash SLEEP_TIME="5" APP="ls *.mp3" DEBUG="1" timer() { if [[ $DEBUG = 1 ]] then echo "Sleeping for $SLEEP_TIME seconds..." fi sleep $SLEEP_TIME run_app } run_app() { if [[ $DEBUG = 1 ]] then echo "Running application.." fi $APP 2>/dev/null timer } case "$1" in start) timer ;; stop) echo "Stopping $0..." exit ;; *) echo "Usage: $0 {start|stop}" ;; esac