You are not logged in.

#1 2009-04-22 19:06:52

Bonner
Member
From: Derbyshire, England
Registered: 2008-09-09
Posts: 45
Website

Running A Command At Boot

After some fighting with it, I got OpenNTPD to manage my system clock, however It requires me to run 'ntpd -s -d' at boot as root for it to synchronise, otherwise it has no effect. Thus I want to be able to run a command at boot as root, but not using rc.local. As I found out that the output of the command simply stops the boot process and it forever sits there displaying the times it synchronises to the server. Any suggestions?

Offline

#2 2009-04-22 19:13:05

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: Running A Command At Boot

create a rc.d/something daemon and background it?

Offline

#3 2009-04-22 19:15:09

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,422
Website

Re: Running A Command At Boot


.:[My Blog] || [My GitHub]:.

Offline

#4 2009-04-22 19:19:16

Bonner
Member
From: Derbyshire, England
Registered: 2008-09-09
Posts: 45
Website

Re: Running A Command At Boot

Ghost1227 wrote:

For some reason the set time doesn't 'stick' It always goes forward a few hours every time I shutdown/reboot, and I haven't a clue why.

Offline

#5 2009-04-22 19:21:41

Bonner
Member
From: Derbyshire, England
Registered: 2008-09-09
Posts: 45
Website

Re: Running A Command At Boot

eldragon wrote:

create a rc.d/something daemon and background it?

Is that as simple as creating a file, say named /etc/rc.d/ntpdcommand, adding the command to the file then adding @ntpdcommand to my Daemons module in rc.conf?

Offline

#6 2009-04-22 19:27:10

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: Running A Command At Boot

Bonner wrote:
eldragon wrote:

create a rc.d/something daemon and background it?

Is that as simple as creating a file, say named /etc/rc.d/ntpdcommand, adding the command to the file then adding @ntpdcommand to my Daemons module in rc.conf?

scan the scripts there, they are fairly simple to replicate

Offline

#7 2009-04-22 19:40:21

hacosta
Member
From: Mexico
Registered: 2006-10-22
Posts: 423

Re: Running A Command At Boot

to run a command at boot you usually add it to rc.local, but there is already an script to start openntpd just add the daemon to your rc.conf

Offline

#8 2009-04-22 19:47:03

Bonner
Member
From: Derbyshire, England
Registered: 2008-09-09
Posts: 45
Website

Re: Running A Command At Boot

hacosta wrote:

to run a command at boot you usually add it to rc.local, but there is already an script to start openntpd just add the daemon to your rc.conf

I know that, however the every time I boot the time advances a couple of hours, which puts it too far ahead for ntpd to synchronise it. It won't synchronise if the clock is too different from the time on the server. Thus it won't synchronise without me issuing 'ntpd -s -d'

Offline

#9 2009-04-22 20:14:42

Statix
Member
From: Hangzhou, China
Registered: 2008-02-16
Posts: 240

Re: Running A Command At Boot

The only problem with it being in /etc/rc.local is that it stops the boot process? Sounds like something a simple & would solve. & backgrounds the process. So you'd run it like:

ntpd -s -d&

If that still doesn't work then yeah, make your own daemon to run the command and have it start before the openntpd one.


Madly in love with Arch64, Openbox, DotA, and of course... penguins!
Happy to help if you're not a Help Vampire. Use your wonderful resources like ArchWiki, Google, and our wonderful search page.

Offline

#10 2009-04-22 20:25:54

dmartins
Member
Registered: 2006-09-23
Posts: 360

Re: Running A Command At Boot

Bonner, are you running Windows on the same PC? It sounds to me like you have Windows installed, which would try to keep your BIOS clock set to your local time and then have linux trying to keep your BIOS clock set to UTC.

EDIT: Except I see you are in England.. so your local time and UTC are probably the same.. neutral

Last edited by dmartins (2009-04-22 20:27:43)

Offline

#11 2009-04-23 06:40:04

Bonner
Member
From: Derbyshire, England
Registered: 2008-09-09
Posts: 45
Website

Re: Running A Command At Boot

Statix wrote:

The only problem with it being in /etc/rc.local is that it stops the boot process? Sounds like something a simple & would solve. & backgrounds the process. So you'd run it like:

ntpd -s -d&

If that still doesn't work then yeah, make your own daemon to run the command and have it start before the openntpd one.

The command had no effect when I ran it in the background. I'll have a crack at writing a daemon tonight. Looks a bit over my head, but i'll still give it a shot tongue

Offline

#12 2009-04-23 06:40:57

Bonner
Member
From: Derbyshire, England
Registered: 2008-09-09
Posts: 45
Website

Re: Running A Command At Boot

dmartins wrote:

Bonner, are you running Windows on the same PC? It sounds to me like you have Windows installed, which would try to keep your BIOS clock set to your local time and then have linux trying to keep your BIOS clock set to UTC.

EDIT: Except I see you are in England.. so your local time and UTC are probably the same.. neutral

Nah, Arch linux only on this. I don't actually seem to have a BIOS clock. There aren't any settings for it in the BIOS.

Offline

#13 2009-04-23 13:45:04

dr/owned
Member
Registered: 2009-01-09
Posts: 136

Re: Running A Command At Boot

Here's what I did to get a daemon working to change my mac address on bootup (I have an nvidia mobile chipset so I have no fixed mac address and have to spoof it to one that I registered with):

http://wiki.tuxisalive.com/index.php/In … Arch_Linux

Scroll down a bit- Ignore the script and filename they display and replace that stuff with your own (which I think is only going to be 1 line).  I think the most important part is chmod-ing the script.

Last edited by dr/owned (2009-04-23 13:45:56)

Offline

Board footer

Powered by FluxBB