Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My /etc/rc.local is:


touch /var/lock/subsys/local


My /data/automatic/ is:

echo "RWQERWER" >> /data/logs/1.log
ntpdate >> /data/logs/1.log

The echo "RW...." is worked,ntp has installed. is 744 , but ntpdate is run failed.

Outside at bash command line ,the /data/automatic/ and ntpdate >> /data/logs/1.log both run successfully .

What should I do ? Thanks first !

share|improve this question

closed as unclear what you're asking by Lucas Kauffman, Wesley, Scott Pack, Falcon Momot, Ward Jul 21 '13 at 5:10

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

What does "is run failed" means? Does ntpdate report an error into /data/logs/1.log? Maybe you get more info if you redirect STDERR as well: ntpdate >> /data/logs/1.log 2>&1 –  Sven Jul 19 '13 at 7:17
I think the issue is that in bash script you must specify full path to the ntpdate. Try to replace ntpdate on /usr/sbin/ntpdate –  ALex_hha Jul 19 '13 at 7:40
@ALex_hha: On my C6.4 the PATH that rc.local admits to is /sbin:/usr/sbin:/bin:/usr/bin - it's very strange. –  Iain Jul 19 '13 at 8:06
That 's the point ! bash and sh .... but even if I use the full path , it doesn't work anyway. –  mike Jul 20 '13 at 4:30

2 Answers 2

I have no idea why you (and I get the same problem) can't capture the output of the command when run from rc.local.

If you want to capture it you can do something like

out=$(ntpdate 2>&1)
echo $out >>/data/logs/1.log

which just worked on a system I have to hand.

share|improve this answer
Actually , it's a very simple question ,you just use my code like my way ,and you will figure out . –  mike Jul 19 '13 at 9:22
@mike: I'm sorry I don't understand your comment. –  Iain Jul 19 '13 at 10:29
I'm so sorry, I try my best to let you understand ,but I am an Aisan , english is so difficult to me . aplogizes! –  mike Jul 20 '13 at 4:32

ntpdate is depreciated. You should install the NTP client and configure the ntpd daemon configuration file /etc/ntp.conf:

# cat /etc/ntp.conf | grep -v ^# | grep -v ^$
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict -6 ::1
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

And start the daemon

# service ntpd start
share|improve this answer
no.I don't mean to use ntpd service ,just the ntpdate ,when ntpdate running,ntpd should closed. –  mike Jul 19 '13 at 7:21
Could you clarify what do you want to get by running ntpdate once at system startup? –  ALex_hha Jul 19 '13 at 7:27
@mike: Are you aware of the differences between ntpdate and ntpd? ntpdate will update the time once when you run it, whereas ntpd will continually update the time. –  Sven Jul 19 '13 at 7:34
I just want to use ntpdate for once update time , not a ntpd service . –  mike Jul 19 '13 at 9:19
@mike - Alex_hha has the right answer. ntpdate has been deprecated. You should be running the NTP client service. –  kce Jul 21 '13 at 4:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.