Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

check time of script

SOLVED
Go to Solution
Super Advisor [Founder]

check time of script

hello,

how can you check the time a script is run;

I want my script to check that it is after 18:00 to ensure the script is not run early

can you help?

Thanks
hello
3 REPLIES
Honored Contributor [Founder]

Re: check time of script

Well, the easiest thing to do would be to schedule the script for a specific time via cron.

This way, you would ensure that it is running after 18:00

man crontab

for details.

Best regards,

Kent M. Ostby
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Highlighted
Honored Contributor [Founder]

Re: check time of script

#!/usr/bin/sh

HOUR+$(date "+%H")
if [ $HOUR -lt 18 ]
then
echo "must run after 10:00, current time is $(date "+%H:%M")
exit
fi
Super Advisor [Founder]

Re: check time of script

Thanks both, Bill has the answer - the job will be setup in cron but I do not wish for the script to be run manually by mistake.
hello