# rdate - Failed to set clock

## nanoczar

I'm at my wits end, thus, a cry for help. I'm trying to use rdate to set my system clock on boot. It has worked for the longest time without fail, but after upgrading my udev, and working through the many issues associated with my RAID and such...I'm not getting the following upon boot:

```
vixie-cron     | * vixie-cron: waiting for rdate (50 seconds)

rdate          | * Failed to set clock

 [ !! ]

rdate          | * ERROR: rdate failed to start
```

But what's odd, before I get these messages above, I have this:

```
rdate          | * Setting clock via rdate ...

 [ ok ]

 [ ok ]
```

So, it seems like it's going to work...and then doesn't. Huh? After I log in, I can do a:

```
/etc/init.d/rdate restart

```

and all is back to normal. Any ideas how I can resolve this?

Thanks!

----------

## wcg

Can you run it from the command line and have it work?

I assume that there are parameters to rdate in /etc/conf.d/rdate.

What are they?

(I use openrdate rather than rdate, and I simply run an hourly

command from root's crontab. There is a script for it in

/etc/init.d/, but I never bothered to have rc-update add it

to the set of init scripts that run at boot. There is no output

from cron unless openrdate fails.

It will sometimes fail for several hours in a row because

the server that it is connecting to, us.pool.ntp.org, is having

problems. I can tell when that server recovers, because I stop

getting emailed alerts from cron that openrdate failed.

I install a local smtp mail server, and I have an alias in /etc/aliases

that redirects all mail to root to a non-root account that monitors

administrative email.)

----------

## nanoczar

I can run the rdate from the command line, immediately after booting (when it fails for some reason), and it works. No idea why it can work immediately after I login.

I removed rdate, thinking it might be something wrong, and installed openrdate to give it a whirl. Same situation. Here's a copy of my boot information. Is there something wrong with local or vixie-cron? And why would it say "Name or service not known" when it works from the command line? It's almost as if my network's not working...

```

   OpenRC 0.11.8 is starting up Gentoo Linux (x86_64)

Press I to enter interactive boot mode

 * /proc is already mounted

 * Mounting /run ...

 * /run/openrc: creating directory

 * /run/lock: creating directory

 * /run/lock: correcting owner

udev-mount     | * Using /dev mounted from kernel ...

 [ ok ]

sysfs          | * Mounting config filesystem ...

 [ ok ]

sysfs          | * Mounting cgroup filesystem ...

 [ ok ]

devfs          | * Mounting /dev/shm ...

 [ ok ]

udev           | * Starting udev ...

 [ ok ]

udev           | * Populating /dev with existing devices through uevents ...

 [ ok ]

udev           | * Waiting for uevents to be processed ...

 [ ok ]

udev           | * Device initiated services: net.eth0

rc sysinit logging stopped at Mon Jan 28 05:57:17 2013

rc boot logging started at Mon Jan 28 05:57:17 2013

hwclock        | * Setting system clock using the hardware clock [UTC] ...

 [ ok ]

sysctl         | * Configuring kernel parameters ...

swap           | * Activating swap devices ...

 [ ok ]

modules        | * Autoloaded 0 module(s)

 [ ok ]

hostname       | * Setting hostname to fractal ...

 [ ok ]

lvm            | * Setting up the Logical Volume Manager ...

lvm            |  No volume groups found

lvm            |  No volume groups found

lvm            |  No volume groups found

 [ ok ]

fsck           | * Checking local filesystems  ...

fsck           |fsck.jfs version 1.1.15, 04-Mar-2011

fsck           |processing started: 1/28/2013 5:57:19

fsck           |The current device is:  /dev/md126p3

fsck           |Block size in bytes:  4096

fsck           |Filesystem size in blocks:  486371891

fsck           |**Phase 0 - Replay Journal Log

fsck           |Filesystem is clean.

fsck           |fsck.jfs version 1.1.15, 04-Mar-2011

fsck           |processing started: 1/28/2013 5:57:19

fsck           |The current device is:  /dev/md126p1

fsck           |Block size in bytes:  4096

fsck           |Filesystem size in blocks:  50195

fsck           |**Phase 0 - Replay Journal Log

fsck           |Filesystem is clean.

 [ ok ]

root           | * Remounting root filesystem read/write ...

 [ ok ]

root           | * Remounting filesystems ...

sshd           | * Starting sshd ...

 [ ok ]

 [ ok ]

mtab           | * Updating /etc/mtab ...

 [ ok ]

localmount     | * Mounting local filesystems ...

 [ ok ]

swapfiles      | * Activating additional swap space ...

 [ ok ]

urandom        | * Initializing random number generator ...

tmpfiles.setup | * setting up tmpfiles.d entries ...

bootmisc       | * Creating user login records ...

 [ ok ]

 [ ok ]

bootmisc       | * Cleaning /var/run ...

 [ ok ]

 [ ok ]

bootmisc       | * Wiping /tmp directory ...

 [ ok ]

termencoding   | * Setting terminal encoding [UTF-8] ...

 [ ok ]

alsasound      | * Restoring Mixer Levels ...

consolefont    | * Setting console font [default8x16] ...

net.lo         | * Bringing up interface lo

keymaps        | * Setting keyboard mode [UTF-8] ...

 [ ok ]

keymaps        | * Loading key mappings [us] ...

 [ ok ]

 [ ok ]

net.lo         | *   127.0.0.1/8 ...

 [ ok ]

net.lo         | *   Adding routes

net.lo         | *     127.0.0.0/8 via 127.0.0.1 ...

 [ ok ]

net.eth0       | * Bringing up interface eth0

net.eth0       | *   10.12.30.5 ...

 [ ok ]

net.eth0       | *   Adding routes

net.eth0       | *     default via 10.12.30.1 ...

 [ ok ]

 [ ok ]

rc boot logging stopped at Mon Jan 28 05:57:24 2013

rc default logging started at Mon Jan 28 05:57:24 2013

dbus           | * Starting D-BUS system messagebus ...

lm_sensors     | * Loading lm_sensors modules...

lm_sensors     | *   Loading coretemp ...

 [ ok ]

lm_sensors     | *   Loading w83627ehf ...

upsdrv         | * Starting UPS drivers ...

 [ ok ]

lm_sensors     | * Initializing sensors ...

upsdrv         |Network UPS Tools - UPS driver controller 2.6.5-Unversioned directory

upsdrv         |Network UPS Tools - Generic HID driver 0.37 (2.6.5-Unversioned directory)

upsdrv         |USB communication driver 0.31

 [ ok ]

 [ ok ]

avahi-daemon   | * Starting avahi-daemon ...

upsdrv         |Using subdriver: Belkin HID 0.15

syslog-ng      | * Starting syslog-ng ...

netmount       | * Mounting network filesystems ...

 [ ok ]

openrdate      | * Setting clock via openrdate ...

 [ ok ]

ntpd           | * Starting ntpd ...

 [ ok ]

 [ ok ]

upsd           | * Starting upsd ...

 [ ok ]

cupsd          | * Starting cupsd ...

upsd           |fopen /var/lib/nut/upsd.pid: No such file or directory

upsd           |ACL in upsd.conf is no longer supported - switch to LISTEN

upsd           |ACL in upsd.conf is no longer supported - switch to LISTEN

upsd           |ACCEPT in upsd.conf is no longer supported - switch to LISTEN

upsd           |REJECT in upsd.conf is no longer supported - switch to LISTEN

upsd           |listening on 127.0.0.1 port 3493

upsd           |listening on ::1 port 3493

upsd           |Connected to UPS [belkin]: usbhid-ups-belkin

upsd           |Unrecognized user setting llowfrom

 [ ok ]

upsmon         | * Starting upsmon ...

upsmon         |fopen /var/run/upsmon.pid: No such file or directory

upsmon         |UPS: belkin@localhost (slave) (power value 1)

upsmon         |Using power down flag file /etc/killpower

 [ ok ]

 [ ok ]

samba          | * samba -> start: smbd ...

 [ ok ]

samba          | * samba -> start: nmbd ...

 [ ok ]

vixie-cron     | * vixie-cron: waiting for openrdate (50 seconds)

local          | * local: waiting for openrdate (50 seconds)

vixie-cron     | * vixie-cron: waiting for openrdate (41 seconds)

local          | * local: waiting for openrdate (41 seconds)

vixie-cron     | * vixie-cron: waiting for openrdate (32 seconds)

openrdate      |openrdate: time-a.timefreq.bldrdoc.gov: Name or service not known

openrdate      | * Failed to set clock via openrdate

 [ !! ]

openrdate      | * ERROR: openrdate failed to start

vixie-cron     | * Starting vixie-cron ...

 [ ok ]

local          | * Starting local

local          | * /etc/conf.d/local should be removed.

local          | * Please move the code from the local_start function

local          | * to scripts with an .start extension

local          | * in /etc/local.d

 [ ok ]

rc default logging stopped at Mon Jan 28 05:57:57 2013

```

----------

## JC99

This is a just a guess but you have openrdate trying to start up after ntpd. Both deal with time. If you disable ntpd at boot does openrdate work the way it should?

----------

## wcg

Here is my openrdate command from root's crontab:

```

## run openrdate to update the system time from a timeserver

@hourly exec /usr/bin/openrdate -4 -a -c -n -s us.pool.ntp.org

```

With that, I do not need ntpd or openrdate to run at boot:

```

rc-update delete ntpd [whatever runlevel ntpd is in]

rc-update delete openrdate [whatever runlevel openrdate is in]

```

I only need cron to be working at boot for the openrdate commands

to update the system time hourly from the remote time server.

I do get a warning from the kernel that openrdate is using a

deprecated sysctl function, so I will probably have to fix that

eventually, switch to ntpdate, or whatever. (When I first installed

Gentoo, ntpdate was not working, which was why I installed

openrdate.)

If you do not serve time updates to other machines (on your

local lan or wherever), you do not need ntpd, a time server.

Instead you only need an ntp client, like ntpdate, rdate, or

openrdate.

(You can replace that crontab line with rdate or ntpdate and

their appropriate command line options, and it should work

the same. You want a "quiet" option, like openrdate's "-s"

option, so that cron does not bother reporting successful

clock syncs. With ntpdate, one would need to use whatever

command line options allow it to work with a NAT router,

unless you have a static IP address. Openrdate worked

through a NAT router right out of the gate for me.)

PS: If you are not in the US, replace "us.pool.ntp.org" with

"[your country code].pool.ntp.org".

----------

