Operating System - HP-UX
1837018 Members
2125 Online
110111 Solutions
New Discussion

Re: script to change date in my crontab

 
SOLVED
Go to solution
aretana
Occasional Advisor

script to change date in my crontab

i have a script in the crontab to change the system date, but not work because is waiting for the answer to response... my script is as follows:

##############
month=12
day=19
hour=`date |cut -c 12-13`
min=`date |cut -c 15-16`
min=`expr $min - 5`
year=2005
chardate=$month$day$hour$min$year
date $chardate
##############


how to make to date command not ask for time backwards?

date: do you really want to run time backwards?[yes/no]Only "yes" will make it take!

thanks
9 REPLIES 9
Sanjay_6
Honored Contributor

Re: script to change date in my crontab

hi,

why do you want to change the date / time using the cron.

Thanks
aretana
Occasional Advisor

Re: script to change date in my crontab

because i have to synchronize my system with other box after the cold backup (at 4:15 a.m)
Bill Hassell
Honored Contributor

Re: script to change date in my crontab

The question is asked for a good reason...setting the date/time backwards can break a lot of date-dependent functions including cron and especially database applications. Changing time/date is so disruptive for many applications that many system adminstrators disable date changes with a command wrapper. Perhaps you can explain the reason to change the time/date at all.


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: script to change date in my crontab

Hi:

To keep your servers with consistent, correct time, use 'xntpd' (NTP = Network Time Protocol).

You can configure this via SAM or by editing a few simple configuration files.

There is an excellent guide in the "Installing and Administering Internet
Services" manual in chapter-7.

You can find an external source to which to synchronize your server, here:

http://ntp.isc.org/bin/view/Servers/WebHome

Regards!

...JRF...
Yogeeraj_1
Honored Contributor

Re: script to change date in my crontab

hi,

Time Server is the way to go!

YOu must configure you servers to synchronize their date/times with that of the Time Server.

You will be more accurate/scientific

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Yogeeraj_1
Honored Contributor

Re: script to change date in my crontab

hi again,

see also:
http://www.ntp.org

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Muthukumar_5
Honored Contributor
Solution

Re: script to change date in my crontab

You got the problem when changing the time in the machine using cron tab? If you want to do after that then,

##############
month=12
day=19
hour=`date |cut -c 12-13`
min=`date |cut -c 15-16`
min=`expr $min - 5`
year=2005
chardate=$month$day$hour$min$year
date $chardate<<-EOF
yes
EOF
##############

will do it.

-Muthu
Easy to suggest when don't know about the problem!
aretana
Occasional Advisor

Re: script to change date in my crontab

Muthu, this is exactly what i want...
thank yuo all for the comments and solutions
aretana
Occasional Advisor

Re: script to change date in my crontab

the reason for make the script is because the server are advanced 5 minuts of the other server, and have a database store procedure that insert data in the other server, but the store procedure validates that the date is not going to be greater than the system date.
This script only will be executed one time, after will be removed from crontab...