3

Newbie question, sorry - I've been googling 'start automatically on reboot ubuntu' and the like, but I'm not sure I've found the definitive answer.

I'm using Ubuntu 10.04 and I would like to make sure that heartbeat starts automatically whenever the server reboots.

Currently I am running the following manually:

$ /etc/init.d/heartbeat start

How can I make sure this is called whenever the server restarts?

One answer I googled suggested:

$ update-rc.d heartbeat defaults

would do the trick - is that correct?

5
  • well, just test it ? Nov 28, 2011 at 11:42
  • running update-rc.d heartbeat defaults says System start/stop links for /etc/init.d/heartbeat already exist. But then when I reboot and run /etc/init.d/heartbeat start it starts happily without saying it's already running. So I'm confused.
    – Richard
    Nov 28, 2011 at 11:46
  • Maybe the 'defaults' command is creating the start script but not actually setting it to auto-reboot?
    – Richard
    Nov 28, 2011 at 11:47
  • after restart type ps axu | grep [h]earbeat if you see something like root 3024 0.0 0.1 12222 12222 ? SLs Nov24 0:08 heartbeat: master control process nobody 3069 0.0 0.0 5672 5668 ? SL Nov24 0:00 heartbeat: FIFO reader nobody 3100 0.0 0.0 5668 5664 ? SL Nov24 0:00 heartbeat: write: bcast eth1 nobody 3101 0.0 0.0 5668 5664 ? SL Nov24 0:15 heartbeat: read: bcast eth1 that means that hearbeat is running, you can try service heartbeat status after restart` also
    – B14D3
    Nov 28, 2011 at 11:50
  • You can use sysv-rc-conf to create the required links to the needed runlevels.
    – Khaled
    Nov 28, 2011 at 12:04

3 Answers 3

2

Type update-rc.d heartbeat defaults

and it will be starting automaticly after reboot

if you wanna turn it off type 'update-rc.d -f heartbeat remove`

2

It should. Basically, the startup process doesn't actually look in /etc/init.d, it looks in /etc/rc2.d (or whatever is defined as the startup run level). The files in /etc/rc2.d should be symlinks to files in /etc/init.d:

$ ls -l /etc/rc2.d
total 4
lrwxrwxrwx 1 root root  14 Sep 19 14:13 K16nsca -> ../init.d/nsca
-rw-r--r-- 1 root root 677 Mar 30  2011 README
lrwxrwxrwx 1 root root  19 Aug 15 17:30 S10syslog-ng -> ../init.d/syslog-ng
lrwxrwxrwx 1 root root  23 Jul  6 20:18 S20chef-expander -> ../init.d/chef-expander
lrwxrwxrwx 1 root root  19 Jun 30 19:46 S20chef-solr -> ../init.d/chef-solr
lrwxrwxrwx 1 root root  17 Jun 30 19:46 S20couchdb -> ../init.d/couchdb
lrwxrwxrwx 1 root root  20 Jul 22 16:20 S20fancontrol -> ../init.d/fancontrol
lrwxrwxrwx 1 root root  15 Jun 30 19:46 S20jetty -> ../init.d/jetty
lrwxrwxrwx 1 root root  28 Jul 22 16:20 S20nagios-nrpe-server -> ../init.d/nagios-nrpe-server

and so on.

For Heartbeat to start up on boot, it should have a symlink along those lines.

You can create these links manually, but Ubuntu uses the update-rc.d command to manage those symlinks, so you don't have to.

Since the /etc/rc2.d directory is root-owned and permissioned, you will need to actually run:

$ sudo update-rc.d heartbeat defaults

to run the command with superuser permissions. When it runs, it should show you the set of symlinks it will create. In addition to the one in /etc/rc2.d, it should put similar links in the other /etc/rc?.d directories, including links in /etc/rc6.d (for example) to shut down the service as the box shuts down.

1

try running the script again, some scripts just say they are started and dont complain at all. Also if I am not mistaking, what you are doing is saying run this script heartbeat, BUT you are not giving the script any arguments. (If I understand this page correctly)

What you can do is make a script named foo with :

/etc/init.d/heartbeat start

make it executable with chmod +x

and then run the command update-rc.d foo defaults

It will run all the commands in the foo script on boot up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .