I need to check for the current time and abort the script if it is not proper time of day I am supposed to run it. Also, if anyone else runs it, it should abort.For example: I need my script to only run if it is started between 10 PM and and 2 AM (a 4 hour window).Currently I am doing the following. Taking the time with date +%k%M and comparing with hard coded numbers#!/bin/shcurrTime=`date +%k%M`check_time_to_run(){    tempTime=$1    if [ $tempTime -gt 200 -a $tempTime -lt 2200 ]; then         echo Time is between 2 AM and 10 PM. Aborting.        exit 1    else        echo Time is after 10 PM and before 2 AM. Running normally.    fi}check_time_to_run $currentTimeI would like to know if there is any other efficient method with respect to time comparision in sh or bash ?
Good method to compare time?
bash;shell;shell script;date;time
That looks perfect to me. What makes you think it should be improved?Anyway, ways to improve it could be:Use a smaller, quicker shell than bash like dash or pdksh.use a shell that has date capabilities builtin like zsh or ksh93use gawk (which is smaller than bash, but not than dash but could avoid the extra fork):Example:#! /usr/bin/gawk -fBEGIN {now = strftime(%k%M)+0; exit(now > 200 && now < 2200)}