Hot answers tagged

146

/etc/init.d contains scripts used by the System V init tools (SysVinit). This is the traditional service management package for Linux, containing the init program (the first process that is run when the kernel has finished initializing¹) as well as some infrastructure to start and stop services and configure them. Specifically, files in /etc/init.d are shell ...


41

When you copy the script into place, don't forget to make it executable and owned by root: sudo chmod +x /etc/init.d/celeryd sudo chown root:root /etc/init.d/celeryd Once you have installed that, you can set it to start automatically on boot with: sudo update-rc.d celeryd defaults sudo update-rc.d celeryd enable


38

Wily Werewolf (15.10) and newer: You don't have to do anything. You are using systemd by default. Trusty (14.04) and older: You are out of luck. Ubuntu repositories do not provide the systemd binaries for versions before Utopic, despite the fact that their sources do generate the files. You can learn more about this in this answer.


36

Your celeryd script is probably not executable, that's why sudo /etc/init.d/celeryd is returning command not found. So, you need to first make it executable. To do so, run the following commands: sudo chmod 755 /etc/init.d/celeryd sudo chown root:root /etc/init.d/celeryd The first line changes the permissions to -rwxr-xr-x, and the second line ensures ...


34

You can also run init-checkconf to check syntax init-checkconf /etc/init/job.conf File /etc/init/job.conf: syntax ok


29

The boot loader will load the kernel, the kernel would attempt to run init, not find it and panic. The way out of it is to reboot, edit the boot parameters, add init=/bin/bash and boot that way. The kernel will use bash as init. This will give you a chance to run commands and fix the system. Correction Apparently the kernel (file init/main.c) does: if (!...


26

The solution is to approach the problem from the other direction: to satisfy the start criteria for Centrify, it is not necessary to make existing services depend on the new Centrify service, rather make the new Centrify service depend on existing services. For example, an Upstart configuration file /etc/init/centrify.conf could say: start on (starting ...


24

First, you can check that your job is actually known to upstart: sudo initctl list | grep your_job_name If it's not found, you can try reloading the configuration and then re-checking: sudo initctl reload-configuration # re-check sudo initctl list | grep your_job_name Then try again to start your job: sudo start your_job_name If you weren't getting ...


22

The setting I am looking for is in /etc/default/rcS, FSCKFIX=yes. This means "automatically repair filesystems with inconsistencies during boot" and causes fsck to run with the -y flag. It was set to no in both of my Ubuntu systems. Even when set to no, the boot time fsck is still somewhat noninteractive. mountall runs fsck with -a, a synonym for -p, which ...


21

Ubuntu 14.04 uses Upstart as the init system, the plan to switch to systemd is planned for 14.10+. There are parts of "systemd" that have been used in Ubuntu for a long time, but for most intents and purposes when people say "systemd" they mean systemd-as-init. Here's some background info: http://summit.ubuntu.com/uds-1403/meeting/22156/core-1403-systemd-...


19

It usually means you have an error in the .conf file - for instance I'm not sure the pid stanza is supported in 10.04, stop can't be used in the script etc. I'd try starting the file from scratch (with only start, stop etc), and then slowly building it up by adding more and more lines and testing it via start pure-ftpd. For example: # cat pure-ftpd.conf ...


19

Ubuntu switched to systemd as its service framework starting in 15.04 for all flavors, including Desktop and Server. The recommended practice is to change your upstart jobs to systemd jobs (see the wiki article for more info). You can also switch back to upstart if you want, which is certainly the quicker fix. I recommend you read the first few sections of ...


17

There is really never any compelling reason to use init 6 instead of reboot, unless: For some reason you are missing the reboot executable, or You are deliberately trying to avoid notifying users that the system is going down. reboot (so long as you don't run reboot --force) is actually the "softer" way to shut down. Consider: init 6 will run all of ...


16

If you do man inittab in your terminal, all shall be revealed: The /etc/inittab file was the configuration file used by the original System V init(8) daemon. The Upstart init(8) daemon does not use this file, and instead reads its configuration from files in /etc/init. See init(5) for more details.


15

The ".d" is usually appended to a directory name to indicate that what used to be (or what could have been) handled by a single script or a single configuration file has been split into multiple files for the sake of convenience, but which should be included, or executed, together. For example, /etc/apache/conf.d/ or /etc/apt/sources.d/ In cases where it's ...


12

I don't trust anything but the kernel to keep a sane state here, so I don't (ab)use init to get this job done, nor do I count on myself actually knowing what is or isn't mounted (some packages can mount extra filesystems, like binfmt_misc). So, for process slaughter, I use: PREFIX=/mnt/chroot-0 FOUND=0 for ROOT in /proc/*/root; do LINK=$(readlink $...


11

Nothing happens, until you try to reboot. As long as the system is running, and you don't try to switch runlevels by running /sbin/init n, you wouldn't even realize it was gone. Actually, deletion of /sbin/init is undoable if you realize the mistake early and stay calm. System administrators have recovered from much nastier "lobotomies" while keeping the ...


10

Upstart is the replacement for the traditional init.d style System-V bootup scripts. However, upstart is more than just a collection of bootup scripts. It allows in fact a minute planning and control of the start of different daemons. For instance, in order to automount network drives, you need first a working network. While before upstart these situations ...


9

James's answer works for a 1 to 1 dependency. For a 1 to many, i.e., to make sure service A starts before services B, C, and D, you need to take another approach. You can look at the current portmap scripts for reference but here is the general approach: create a wait script. Scenario: you want your Service A to always run before service-b, service-c, and ...


9

(Answered by OP) Got it myself! when new jobs are inserted into /etc/init then the update is not noticed until the next check. Myscript is at lot faster then check frenquence so the update needs to be initiation ny hand: sudo initctl reload-configuration Now it works as expected.


8

As you point out, the ".d" nomenclature is puzzling and strange, and doesn't really have any place in any modern system -- you'll notice that most modern services have tended to drop it. The reason the directory is /etc/init and not /etc/upstart is because Upstart is the project name, the actual installed binary is still /sbin/init thus it would not make ...


8

From Bellum PLC Forum - Ubuntu 11.10 init 100% cpu usage bug: I noticed an CPU usage issue with init due to upstart, Which was eating 99% ram constantly. and i decided to find working fix. This is a bug which has been confirmed by Ubuntu but below is a simple quick fix patch which should work completely for all. Firstly Open up SSH and add the ...


8

Marty Fried's answer contains the one most valuable info: the Cookbook. Reading thru that makes you more than able to write your init scripts. However, messing with init.d, rc*.d, chkconfig et al, is not what you want to do. On Ubuntu (and other distros), they're just remains of the old sysvinit stuff which many packages still use or just support for legacy ...


8

You cannot make a script that runs from init.d and displays a gnome-terminal window, because scripts in init.d run before there is any login session in which to display one. They run even before the graphical user interface is running. Logging to a File Instead If you need to run this script when the machine boots up, then instead of trying to make it ...


8

To show what init process is enabled: # readlink /sbin/init By default on 14.04 and 14.10 it's "upstart" Changing this would involve alot more configuration than just changing this symlink so don't do that. This file is nearly always a simlink. In this case the link path does not start with / so this is a path relative to the symlink file to /sbin/...


7

MySQL is started by upstart. You can find the configuration file at /etc/init/mysql.conf


7

There you go /sbin/init: No such file or directory. Looks like it can't find a /sbin/init on /dev/sda6. Maybe have a look from a Live CD, and see what is on sda6? Is it the right partition? Is just that file missing? You can probably fix it from a Live CD, but I'm not sure what caused it, so I can't give instructions. Reinstalling is probably easier, if ...


6

The most relevant reference for job file syntax will be available when you run the command: man 5 init on your system. For Ubuntu 10.04, as you found in the previous answer, the pid file syntax is incorrect. Any time you get that 'unknown job" error back, its a good idea to check the logs (pre 11.04, /var/log/daemon.log, 11.04 and greater everything goes ...


6

What does each of these do? networking: #!/bin/sh -e ### BEGIN INIT INFO # Provides: networking # Required-Start: # Required-Stop: $local_fs # Should-Start: ifupdown # Should-Stop: ifupdown # Default-Start: # Default-Stop: 0 6 # Short-Description: Raise network interfaces. ### END INIT INFO Regarding the package ifupdown ...



Only top voted, non community-wiki answers of a minimum length are eligible