I'm not clear on how to start a service when the server boots, I read on some of the other questions asked about adding the script to /etc/init.d
, but It's just one line that I need to execute in the commandline:
sudo /etc/init.d/avahi-daemon restart
But I have a few issues with this, firstly, I apparently need to use sudo, and it gives me the following:
ngl-server-01:~% sudo /etc/init.d/avahi-daemon start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service avahi-daemon start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start avahi-daemon
But when I try just avahi-daemon start
I get:
Too many arguments
Why is this? and how would you start this service?
Update
Similarly, how can I mount a disk on boot as well?
If avahi-daemon is in /etc/init.d and you want to have it started at each boot, just add it to the startup scripts with:
But i'm surprised that avahi-daemon is not still linked in the required runlevels as it was probably added by the system.
To have your disk mounted at boot, add a line in your fstab like suggested by Richard.
You can start the service manually by using
and not using
If you want it so the service starts at boot. You need to have a look at adding a symlink to /etc/rc2.d/ to point at /etc/init.d/avahi-daemon. It is probably easier to read up on the programs
sysv-rc-conf
orupdate-rc.d
For mounting a disk you need to edit /etc/fstab with the correct details. You need to know the device you are trying to mount (eg /dev/sdb1), the mount point (eg /mnt/data)and the filesystem.
The entry in fstab will look something like this:
I had a problem getting avahi-daemon to start on system startup in Ubuntu Server 12.04 even after doing
sudo update-rc.d avahi-daemon defaults
and I've solved it by changingAVAHI_DAEMON_DETECT_LOCAL
from1
to0
in/etc/default/avahi-daemon
(as proposed here).My understanding of the problem is that avahi-daemon started before my server was ready for networking. It tried to detect "unicast dns servers", obviously failed and exited afterwards. This is the default behavior. By changing
AVAHI_DAEMON_DETECT_LOCAL
to 0, I told avahi-daemon not to look for these servers when it starts.I've also figured that I did really not need to run
sudo update-rc.d avahi-daemon defaults
, so user MatToufoutu was right to doubt.