Operating System - HP-UX
1753773 Members
5064 Online
108799 Solutions
New Discussion юеВ

Re: Check in script to make sure it only starts after Midnight.

 
Brad Sheldon
Occasional Advisor

Check in script to make sure it only starts after Midnight.

Hi   there,   we have a script which we need to run after midnight. 

I need  a check in the script to make sure it is starting up  at midnight or a minute after as it invloves DB reorgs which must only be run after 12:00am.

I have done some testing but have only come up with some perl snippets.

the below code checks for the previuos day but i need it in korn

perl -MPOSIX=strftime -le 'print strftime "%m/%d/%Y",localtime(time-86400)'

 

Cheers Brad.

 

 

2 REPLIES 2

Re: Check in script to make sure it only starts after Midnight.

ACS's date hammer does that sort of operation in shell script:

 

http://www.cmve.net/~merijn/caljd-2.25.sh

 

Usage is included and pretty straightforward

 

Alternatively get GNU date from the GNU coreutils (and run-time dependencies) here:

 

http://hpux.connect.org.uk/hppd/hpux/Gnu/coreutils-8.14/

 

with GNU date you can do plenty of simple date arithmetic like

 

date --d "-1 days"


I am an HPE Employee
Accept or Kudo
Dennis Handly
Acclaimed Contributor

Re: Check in script to make sure it only starts after Midnight.

Any reason you don't just schedule the script with crontab and don't put the check in the script?