date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,387,757,805,000
What is the proper way to update an init script an ubuntu system? I am trying to upgrade my version of gitlab from 6-0 to 6-1, part of the upgrade consists of replacing the init script. Upgrade instructions - step 6 sudo rm /etc/init.d/gitlab sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitl...
To debug bash or shell scripts, it's useful to either run it with bash -x or edit the script and add a line saying set -x. This will show the execution trace of each line in the script as it is executed, along with the value of variable assignments.
How to update an init script
1,387,757,805,000
I'm running into a strange (to me) problem. I'm running a gentoo with two net interfaces: enp5s0 (wired interface) and wlan0 (wifi). When I try to run a program, for example openvpn, from its script in /etc/init.d, it outputs: * WARNING: openvpn is scheduled to start when net.enp5s0 has started and doesn't start if ...
Ok, so reading the comments in configuration files does work sometimes... I was right supposing that net works as a "virtual dependency" in the sense that more than one service can actually provide it. And it is actually documented that way in the manual: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&c...
"provide net" in gentoo init script doesn't work as I thought
1,387,757,805,000
I've created a gentoo-live system which should be booted from a CF-card. The whole file-system is in a squashfs. I've created a custom initrd which first mounts the CF-card and from there the squashed filesystem into what will become /. I'd like /etc to be writable so I've copied it to the CF-card added a bind. This h...
BusyBox's built-in mount command doesn't recognize -B; you'll have to use -o bind: mount -o bind /mnt/flash/etc /mnt/root/etc Also, I think the remounting is unnecessary if /mnt/flash is already writable. But try fixing the bind mounting first.
Mount /etc from disc into squashfs
1,387,757,805,000
Here's how I configured my kickstart system initialization script (this is a kickstart conf script snippet): ... %post --log=/root/ks-post.log --interpreter /bin/bash cd /root curl --silent --show-error --retry 5 -O "https://mysecurewebsite.net/init-script7.sh" cp init-script.sh /etc/init.d/initializesystem chmod +...
As you indicate yourself, as root you can just write things to /dev/tty1. If your script does write to stdout you can use: yourscript | tee -a /your/log/file > /dev/tty1 if the script directly writes to the log file things are not so easy, you would have to follow the log file and display new content. In that case it...
Run a script as root during boot and display in the default linux terminal?
1,387,757,805,000
I've been studying process management using shell scripts and I'm starting to realise how difficult it is to make sure that it's done right. For example, you can record the PID of a program to a file, wait on it, and clean up the PID file after the program exits. If you were to try and kill this daemon from an init sc...
You are correct to suspect that there is a (small!) atomicity problem. No matter what method you use, whether it's a system-standard utility like start-stop-daemon, a roll-your-own PID file, using pkill to query and kill by user ID, by executable binary, or whatever, there is always an interval between finding what pr...
Process management and pkill
1,387,757,805,000
Apologies if this is an obvious answer, I am a Windows admin professionally and only use Linux in my homelab to try to learn new things - so I'm very inexperienced with Linux. I am working on writing a Puppet module to install/configure Sonarr, and am running into trouble with getting Sonarr set up as a service (testi...
I wound up finding the issue, or possibly issues. I first noticed that in my Puppet code that was creating the user to run the service, the variable for the user's home dir was misspelled (which caused the user's home dir to be set to "/home/" in /etc/passwd). Second, I realized that Puppet does not automatically crea...
Trying to create a service but it won't start
1,387,757,805,000
I have a Raspberry PI running the standard Raspbian distribution. I have this little C program that I need to run at the very end of the shutdown sequence. All it does is send a couple of logical high pulses on a GIPO output to a power supply to tell it to cut the power to the Raspberry board. The shutdown script shou...
The numbering requested is ignored by dependency based meta init systems. you have the wrong provides!. The critical clue is from another script. lets take a look at umountroot: ### BEGIN INIT INFO # Provides: umountroot # Required-Start: # Required-Stop: # Should-Stop: halt reboot kexec # Default-Start...
Creating a shutdown only script with update-rc.d
1,387,757,805,000
Why is it that I have to type /etc/init.d/apache2 (args) in order to run apache?? Isn't there a way to just apache2 args ??
You don't normally type a command to run Apache: it starts when the system boots. Scripts in /etc/init.d start services and are executed automatically at boot time, if your system is set up correctly. With most distributions, services are enabled by default and will start unless you've done something to disable them. ...
Executing programs without having to specify a directory?
1,387,757,805,000
So I am trying to start a service on systemd enabled system. Name of service is ossec-hids-authd which is the authentication engine(agents) in ossec(Intrusion Detection Software). When I go and start the init script then systemctl times out and on getting the status I am seeing this error. /etc/init.d/ossec-hids-authd...
systemd parses an init script's comments to generate temporary .service file at boot or upon daemon-reload command. Change the line # pidfile: /var/run/ossec-authd.pid to # pidfile: /var/ossec/var/run/ossec-authd.pid and run systemctl daemon-reload UPD: now I see that pid file name is generated by authd at runtime a...
systemd failing to recognize pid file
1,387,757,805,000
Why programs run at boot/shutdown are written in bash script? If a compiled language (or a faster interpreted language, like Python) was used, then its running time would be shorter.
It is largely historic, partly a matter of control from a system administration aspect, partly a portability issue, partly a debugging issue. "Back in the day", there was no autoconf, dpkg, rpm. You downloaded the software, sometimes from UUCP, compiled the product and determined - with your own conventions - where t...
Why is bash used in boot scripts?
1,387,757,805,000
I'm porting a Debian init.d script to CentOS. In the Debian script, it uses start-stop-daemon for launching the process. The script uses start-stop-daemon's --group flag to change to a different group-id when starting the daemon process. How do I set the group-id of the daemon process in the init script on CentOS?
CentOS init scripts use /etc/init.d/functions, which declares a "daemon" function that most other init scripts use. But daemon doesn't accept any group flags. It ends up calling: $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*" A quick /sbin/runuser --help shows that runuser accepts a flag to s...
How do I set the group (gid) of a process I'm about to launch?
1,387,757,805,000
I am trying to change user in order to execute a specific command during startup. It fails silently and apparently the userchange isn't carried out as I can tell that the command isn't executed. What am I doing wrong in my below shown initscript? respawn console none start on startup stop on shutdown script su -u...
I'm assuming you are running recent version of ubuntu or a distribution based on upstart. You can check /var/log/daemon.log for errors. The standard su takes the syntax su [options] [username]. Checkout man 1 su. You might want to try : su -c "myCommand" anotheruser >> "myLogfile.log" Also, a couple of things would ...
Changing user in a script?
1,387,757,805,000
I have set up an init-script to control the state of a VirtualBox VM: #!/bin/sh #chkconfig: 35 99 5 #description: vTiger virtual machine ### BEGIN INIT INFO # Provides: vtigervm # Required-Start: $local_fs # Requider-Stop: $stop_fs # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: Manage vTiger virtua...
Idea #1 Try putting a -x at the top of the service script, this will put the shell into debug mode so that you'll get any output that's being generated by the script. #!/bin/sh -x Idea #2 Also you might want to add the process name to the top of the chkconfig comment macros as well. # processname: vtigervm You may n...
An init-script does not get called on shutdown
1,387,757,805,000
I created a small script backup_files.sh and placed it in /etc/init.d: #/bin/sh logfile=/media/verbatim/log date >> $logfile rsync -av /home/philipp/Documents /media/verbatim/ >> $logfile I would like this script to be executed whenever the computer is rebooted or shut down, so I did the following: sudo ln -s /etc/in...
Finally found out that I had to give them particular file names: sudo ln -s /etc/init.d/backup_files.sh /etc/rc0.d/K10backup_files.sh sudo ln -s /etc/init.d/backup_files.sh /etc/rc6.d/K10backup_files.sh The scripts in /etc/rc0.d and /etc/rc6.d are executed at the time of shutdown and reboot respectively. The scripts ...
Running script before shutdown seemingly not working
1,387,757,805,000
I am trying to get an init script running that starts nodejs as a daemon. The problem is, that when I executing start-stop-daemon it always returns '0', regardless of what error the nodejs-daemon may return. I got as far as figuring out that the issue arises when using start-stop-daemon with the --background switch. W...
This is documented behavior. The foreground process completes after forking the background process. From the man page: -b, --background Typically used with programs that don't detach on their own. This option will force start-stop-daemon to fork before starting the process, and force it into t...
start-stop-daemon always returns '0' although the process fails
1,387,757,805,000
I built ntpd from source, which process put it in /usr/local/sbin. Of course, the ntp service points to /usr/sbin. So, I thought I could just change the path in the init.d configuration file like this: ### BEGIN INIT INFO # Provides: ntp # Required-Start: $network $remote_fs $syslog # Required-Stop: $network...
You've built ntpd without the --enable-linuxcaps option. Without this, ntpd won't recognise the user option -u. Your options are: Recompile with the correct option Remove the -u $UGID from the NTPD_OPTS line in /etc/init.d/ntp
Unable to start locally-built ntpd from system service script
1,387,757,805,000
I am using raspbian. (Debian variant). By default, openvpn is started with /etc/rc2.d/S03openvpn. I set up an /etc/init.d script with a symlink /etc/rc2.d/S04daemonname for a daemon I want to start after openvpn has started and a connection to my vpn provider has been established. The openvpn startup and connection w...
You can run scripts from openvpn with e.g. the --up scriptname option. This would seem to me to be better than expecting the connection to be established a certain time after starting the openvpn process. You may have to experiment a bit with the possible ways of running scripts from openvpn, e.g. not using --up but i...
Run daemon on startup in Debian once openvpn connection established
1,387,757,805,000
I have set up start-stop-daemon to start my script automatically case "$1" in start) log_begin_msg "starting foo" start-stop-daemon --start --chuid nobody --user nobody --pidfile \ /tmp/foo.pid --startas /usr/local/bin/foo.sh & log_end_msg $? the problem is, it always returns 0 (success),ev...
You are not capturing return code of start-stop-daemon. Your problem is that you are launching it in the background and it is started properly. I mean that you are capturing return code of starting something in background that wants to start something in background. Try this: rm /tmp/not_existent_file & echo $? This ...
start-stop-daemon returning always 0 (success)
1,387,757,805,000
I have a bunch of PUIAS (RedHat) 6.4 servers and desktops. I noticed after rebooting my computing nodes (done just for testing purposes) that many of the daemons which are started manually after initial installation (ipmi, mcelog, fail2ban) are not running and have to be restarted manually. This server is suppose to r...
(I'm not trying to be pedantic, I just don't know how much you know or don't know, so I'm basically braindumping here) First off, just be aware that Red Hat picks weird stuff to install and enable by default. For instance it's either RHEL5 or RHEL6 that will install avahi and enable it to start at boot. I think both v...
Daemons not starting during the boot on PUIAS (RedHat) 6.4
1,387,757,805,000
I am writing a script to do some tasks at boot up time in my Debian Wheezy AWS EC2 AMI. Sources on the internet say that usual way to do this is to use update-rc.d to install the symlinks needed to set it up to run at boot time. However, when I try this, I get the error $ update-rc.d -bash: update-rc.d: command not fo...
Looks like you're trying to use update-rc.d as an unprivileged user? Since this tool is located in /usr/sbin/ you probably don't have it in your $PATH. So try running it as root user or call it via sudo update-rc.d.
How to make a script run at boot time in Debian Wheezy?
1,387,757,805,000
I have a daemon/service (milter-regex), that is dying. I'm only using it temporarily (A few months), so don't care too much, but I want it to restart when it dies. It is an init.d script. 'service milter-regex start' etc. The init script lives at /etc/init.d/milter-regex I know if I have something in /etc/inittab, it ...
Scripts in init.d don't get rerun automatically when the service crashes. If you want to do the minimum amount of work to make sure it runs, inittab may be your best bet. It's icky though, almost as icky as still running RHEL 4.
/etc/init.d/script, or /etc/inittab - respawn on die
1,387,757,805,000
Cleaning up the boot process of a Debian squeeze installation running on kernel 3.2.0-0.bpo.3-amd64, I spotted several mountnfs scripts in /etc/init.d/: # ls /etc/init.d/ | grep mountnfs mountnfs-bootclean.sh mountnfs.sh umountnfs.sh Removing fails, with commands like: # update-rc.d -f mountnfs remove update-rc.d: us...
To check which package a file belongs to, use dpkg -S: $ dpkg -S /etc/init.d/mountnfs.sh initscripts: /etc/init.d/mountnfs.sh mountnfs.sh belongs to an essential package called initscripts. Unless you wrote them, you should never remove scripts from /etc/init.d/. That is why the utility update-rc.d exists: to remove ...
How to correctly remove mountnfs from /etc/init.d/
1,387,757,805,000
I recently moved a home-grown service I had running on a virtual machine (Debian 7.8) to a physical computer (Debian 8.5) and after the move, my init script stopped working. I understand there were some major changes to the init process etc. between Wheezy and Jessie, but so far as I can tell, the changes should still...
You should probably consider converting to a native systemd Unit as your init script is fairly typical, and you could for example entirely remove the stop code and let systemd's default mechanism work for you, since you have a PIDFILE where it can check that the daemon is running and so knows how to kill it (see man s...
Debian 7 to 8 Init script trouble
1,387,757,805,000
Raspbian Jessie uses systemd and most system startup processes seem to be run from .service files. There are still a lot of SysV init entries. I gather from reading various articles that Debian 8 has support for both systems. Can anyone explain which SysV init entries are still supported and which not? How does system...
Can anyone explain which SysV init entries are still supported and which not? There isn't a list, and it depends from the script and how well-behaved, bug-free, and conformant to RedHat/LSB conventions it is. How does systemd call init entries? Does it ignore if corresponding .service is running? It does, albeit i...
Explanation of systemd startup
1,387,757,805,000
Various older Linux distributions, which support System V type init scripts, require one to add LSB header to init script. For example a LSB header from /etc/init.d/sshd from OpenSUSE 11.4: ### BEGIN INIT INFO # Provides: sshd # Required-Start: $network $remote_fs # Required-Stop: $network $remote_fs # Default-Start: ...
On debian it's update-rc.d which calls insserv (which is not usually run directly). On Suse it is probably chkconfig. You can read about it here: suse 11 (note: this all changes in openSUSE 12, which has adopted systemd).
Which utility reads LSB headers in System V style init scripts?
1,429,141,439,000
I have the init.d script show below. I want to start the daemon with the argument --http_root /tv When I start the application without the daemon the argument is accepted However I cannot seem to figure out how to adjust the script below to start the daemon with that argument. I want the argument to be passed every ...
If you don't want to modify the init.d script, change (or create) /etc/default/tvheadend as steeldriver pointed out in his comment, edit (add, extend) the entry: TVH_HTTP_ROOT=/tv This file gets sourced in the init.d script, with this line: [ -r /etc/default/$NAME ] && . /etc/default/$NAME and then [ -z "$TVH_HTTP...
Passing variable in init.d script
1,429,141,439,000
We have a startup script that is symbolicly linked to /etc/rc0.d/K01ourapp. Apparently, it is not working as expected during shutdown. The script actually does a few echo calls that may help in troubleshooting. Where does that output get logged (if anywhere)? I am using RHEL5.
Strings sent to the standard output go to /dev/console (most often you can see them on your screen, but not always). To log these messages, you can use bootlogd, which, as described in its man page, "runs in the background and copies all strings sent to the /dev/console device to a logfile", and the default logfile is...
If a start-up script in `init.d` has standard output, where is that logged if anywhere?
1,429,141,439,000
At work, I'm running linux, and use vagrant on a daily basis. What I find annoying is that the system often hangs when I reboot/shut down, if I forgot to vagrant halt any virtual boxes I may have fired up. To counter this, I'd like to write a shutdown script, along the lines of: #! /bin/sh cd ~/vagrants/vagrant_1 vagr...
If you don't do something special vagrant is a wrapping for virtualbox. You can get a list of running virtualboxes: vboxmanage list runningvms and parse the output to get a vmname, then do: VBoxManage controlvm <vmname> acpipowerbutton Have to do this as the user that started the VMs Put a link to the script in /etc...
local shutdown scripts (do's and don't's)
1,429,141,439,000
I have centos 6.4 machine. I created my own script using /etc/init.d/ . Below is the snippet which I took from the net and tried it. The problem now I notice which loading my os when this is loaded it start to work and it can't move to load all the whole os any more. What can I do as I can't access the system now. #!/...
According to this line # chkconfig: 2345 95 05 in your script, you should be able to boot the system into single user mode and then to disable automatic startup of the script (script is enabled in runlevels 2345 by default). How to boot it in single user mode? At the GRUB splash screen at boot time, press any key t...
/etc/init.d/ script starts during loads and crash the system
1,429,141,439,000
I successfully installed a script to automatically launch in /etc/init.d on my new Raspberry Pi. Unfortunately, it is a node.js app that never returns, and therefore hangs the device during boot (this is on Debian). Yes, I'm an idiot. Is there a secret handshake I can do during boot to prevent it from running my i...
Assuming that the node.js init script runs before sshd or any other external access script (otherwise, you could just login in remotely, disable the script, and then reboot), the easiest thing to do is to take your SD card to another computer and mount it there, find the init script, and move it out of the init direct...
init.d script causes boot hang
1,429,141,439,000
i'm just moved to linux world in ubuntu 10.10. i'm using it for normal life, internet and social networks, multimedia enterainement like musics and movie, a bit of coding with c and python.. i've just learned something about run levels and about init and service command line tools. i understand they are powerful tools...
They are used to start (initialize) the system and bring up servers. As a normal user you shouldn't have to worry about them. If you want to also turn you machine into, say, an HTTP (web) server you would have to deal with it. Different distros do that differently, however. Many at least have a service command to star...
how can 'init' and 'service' command can cross normal-user life?
1,429,141,439,000
I could use some help with what I think is a basic request on the newest edition of Linux Mint (which I think would also be applicable to Ubuntu). I have a home system with 3GB of RAM and accounts for family members (4 of them). As the initial login process takes 15-20 seconds and kids are impatient, I'd like a way to...
Assuming you already have one user that auto-logs in, you can probably use a script that runs after logging in (use gnome-session-properties) that: gets a list of users to auto-login from some file checks for each of those users if they are logged in yet if one is not, use xdotool to switch to the first user (by sim...
Auto-start multiple background user sessions in Linux Mint
1,429,141,439,000
I'm trying to write a script that can set a service to: automatically restart after killed automatically start during boot up I can do this by using /etc/inittab but some of the AIX server that I'm working on don't have inittab. Meaning I cannot set the service to behave like the one in inittab. While I was tryi...
One of the solution that I found is to use the rc.d directory. Use sshd as example since this process didn't use inittab but can still start automatically during boot up.
Start a service at boot and automatically respawn it if it dies under AIX
1,429,141,439,000
I'm making a special "installer" for an embedded system where I'd like the kernel to boot up, execute a set of things very late in the process where the peripherals have been set up and then reboot the system without the login prompt ever happening. I'm vaguely familiar with init and runlevels, I presume at this point...
For Debian 7 and earlier, the easiest option is to put your code in /etc/rc.local. This runs at the very end of the boot sequence, just before the login screen is displayed when you boot into console mode, or just before X is started otherwise. Until this script exits, nothing else happens, so if you reboot the system...
Late running of scripts during bootup, ending with a reboot without the login prompt
1,429,141,439,000
It's a fresh install of Sabayon Linux. I installed mysql (equo install dev-db/mysql), configured it (emerge --config ...), but it doesn't start using /etc/init.d script: # /etc/init.d/mysql start * WARNING: mysql is already starting # /etc/init.d/mysql status * You are attempting to run an openrc service on a * sys...
Some of services run by process manager such as : upstart, systemd, OpenRC (your case) , SysV and so on. if get ps ax |ergep -i mysql you'll find out myql is running, Use the following documentation: OpenRC doc
Sabayon - mysql (and other services) won't start
1,429,141,439,000
I have installed VMware Player on my Debian squueze, but after the reboot the vmware daemon(/etc/init.d/vmware) does not start up automatically, i have tried without any success to set the daemon startup with insserv : insserv vmware but it gives me the following output : insserv: warning: script 'K01vpnclient_ini...
LSB tags are the "Linux Standard Base" script headers that tell insserv and chkconfig how to create the companion rc.? scripts. You have to create a LSB header and re-run insserv Edit: Rather after actually taking the time to look at all your information it may have the LSB header but not configured correctly. Search ...
VMWare daemon doesn't startup when system starts
1,429,141,439,000
Background: I'm a Ubuntu/Debian fan and most of my development experience has been on that platform but my current employer uses Redhat. I needed to write a simple init.d script and want the resulting program to run as an unprivileged user. Most resources I found suggest using the daemon function in lieu of start-stop...
You can certainly change the daemon function to set the group or you can write your own mydaemon function to do it. Or in a simplest possible way just call the runuser command that daemon() uses to start your program with particular UID and GID
Why does Redhat's daemon function not have a group setting?
1,429,141,439,000
Using Debian 9 stable, I want to start a custom shell script before starting NGINX processes and shorewall firewall: Do some init work Mount a directory (overlayfs) to overlay /etc with NGINX configuration, shorewall configuration and /etc/hosts The script also ends with sync, not sure if it's a good idea systemctl...
If you don't specify the type of your systemd service, it defaults to Type=simple. This means the service is considered started at the moment its main service process has been forked off (at which point it isn't even executing the ExecStart command yet). You probably want to use Type=oneshot instead, which waits for t...
systemd: finish the execution of custom shell script before starting nginx
1,429,141,439,000
I have a script in /etc/init.d that I'm trying to add echo statements to...but all of my changes seem to be ignored. I'm guessing because the script itself is not actually run but that systemd is doing something behind the scenes to continue running the old version of the script. Is there a way to "load" these chan...
No, there's not a way for systemd to load the changes you made to files in /etc/init.d because systemd is largely ignoring the files anyway. See the gory details at How does systemd use /etc/init.d scripts?. Consider asking a different question about the specific problem you are attempting to solve by editing /etc/ini...
How can I modify an init script on CentOS 7?
1,429,141,439,000
I installed octoprint to my raspberry pi earlier this year in order to control my 3d printers. I've been able to make the pi control 2 printers at once using octoprint. Also I've added a second camera (USB) to view the second printer. I managed to find a way to start the second camera and edit octoprint to see the dif...
Make the startup script do the cd before running mjpg_streamer, just like you're doing manually: #!/bin/sh cd /home/geilisa/mjpg-streamer ./mjpg_streamer -i "./input_raspicam.so -fps 5" -o "./output_http.so -p 8090" This is assuming that your home directory is /home/geilisa. You can't use ~ in the script since it's ...
Writing start script with different working directory
1,429,141,439,000
TL:DR: In which init level /etc/profile or /etc/environment files are read? I want to create a service (/etc/init.d/myservice) starting a shell script located at /opt/myservice/myservice.sh. However this location (/opt/myservice/) is defined at installation time, so it's not a fixed location. Let's say that I set an ...
You may be looking in the wrong place to store application configuration information. /etc/profile is used for the configuration of default settings for login shells (e. g. when SSHing in and invoking bash as the login shell). It purpose is not for the configuration of application installation locations and the like....
In which init level /etc/profile or /etc/environment files are read?
1,429,141,439,000
I wrote a daemon which watches for files in certain directory and if a new file is copied to this directory, then it is committed to SVN. New files appear in this directory only if remote devices copy files there over scp. Now I would like to create a System-V init script for this daemon in OpenSUSE 11.4. It's clear t...
According to https://wiki.debian.org/LSBInitScripts in the section on Required-Stop Normally you would include here the same facilities as for the Required-Start keyword. Having this script running before ssh starts isn't a problem like you suggested in the OP it just means this daemon will be waiting for files th...
"Required-Stop:" line in System-V type init script LSB header
1,429,141,439,000
Is it a bad idea to put variables needed by a daemon program running at boot on a headless system in /etc/profile.d/? From my understanding profile.d doesn't get executed until someone logs into the system via an interactive shell. So would my daemon process that will eventually need the system variables held in profi...
It's a bad idea if it doesn't work. I think your concern about profile.d not running unless someone logs in is legitimate. Put an init script in /etc/rc.d/init.d (I think this is the correct directory for Red Hat; in Ubuntu it's /etc/init.d) to start your daemon. In this script you can declare/define any variables y...
profile.d on headless server
1,429,141,439,000
My rc.local is stuck in an infinite loop since I accidentally put a wrong I/O redirection in and it's executing itself over and over again. I'm on Red Hat 6.5 and would like to know how I can start the machine without the rc.local being run so that I may fix the problem? It is also on a virtual machine and not a phys...
Boot into single user mode by going into the Grub menu and select the kernel version and press e to edit press space and type single
rc.local hang on bootup
1,429,141,439,000
So you may get a better idea of the context, this idea comes from the specific problematic of "letting kids being progressively responsible of their own devices". So I was wondering if there is any possibility to prevent power-on in specific periods of time in order to keep computer usage in the negative ones (an exam...
Your operating system can’t prevent power-on; that would be controlled by the system firmware (but I’ve never seen anything like that). You can force the system to power off if it’s switched on though, e.g. with a cronjob like * 0-16 * * * /sbin/poweroff to power the system down if it’s on at any time between midnigh...
How to schedule a period of time in which power-on or log-in is prevented?
1,496,804,509,000
I created a script to disable the touchpad in my computer. It works ok when I run it in a terminal. I did some work to make it start at startup because I wanted the touchpad to be disabled permanently, but the script did not work at startup. The touchpad was still enabled after startup. This is my configuration: root@...
You have (at least) two choices: Don't load the driver of touchpad into kernel, so echo blacklist [yourdriver] > /etc/modprobe.d/nomouse. Then do a reboot, or manually remove it: rmmod [driver]. synclient only runs after you started X, so put this synclient command to ~/.xinitrc or to /etc/X11/Xsession.d/ or make it...
Disable touchpad in init script
1,496,804,509,000
I have installed X11VNC and starting it on a running System (with X and XFCE running) in a terminal does work. I have written a startup script (used the skeleton in /etc/init.d/skeleton) for that. Runnin that script in a terminal after boot service x11vnc start does actually start the server. Although for some reaso...
After looking around for longer time, I finally found a solution. Using xinetd. I removed the init script from /etc/init.d/ again and did the following. apt-get install xinetd Create content into file /etc/xinetd.d/x11vnc service x11vnc { type = UNLISTED disable = no socket_type = stream protocol = tcp wai...
Creating X11VNC Server Initscript not successful on boot (manually started works)
1,496,804,509,000
I tried installing atftpd today. The package installed successfully: # zypper se atftp Loading repository data... Reading installed packages... S | Name | Summary | Type --+-------+---------------------------------+-------- i | atftp | Advanced TFTP Server and Client | package But the ser...
Why does the service refuse to start? What can I do to fix it? Because you're starting the wrong thing. Start the right thing. ☺ The giveaway here isStandardInput=socket in the service unit file. This indicates that the dæmon is expecting a socket as its standard input, and systemd is expected to supply it when s...
atftpd won't start on opensuse tumbleweed under systemd
1,496,804,509,000
I use Debian Lenny (I know lenny is old and other bla bla) and would like to place a program on the start-up. I use update-rc.d by adding an executable file on /etc/init.d. By referring to http://wiki.debian.org/LSBInitScripts , I need to add a LSB on /etc/init.d/myprogram ### BEGIN INIT INFO # Provides: mypr...
As far as it's concerned in this context, they're the same thing. The LSB information is just metadata in the form of shell comments added to the init beginning of the script. Just combine those two chunks. It should contain: The interpreter line (e.g., #!/bin/sh) The LSB information, edited to your application's nee...
adding a program on start-up by using LSBInitScripts
1,496,804,509,000
I'm running Red Hat 5.1. I have a script called sysinit that I added as a service using chkconfig --add sysinit. I have the following set in the file: #chkconfig 4 01 01 This creates one symlink in my rc4.d directory for S01sysinit. However, I want the script to be run on startup and shutdown. No matter what I do...
The solution I found was to add the following code: touch /var/lock/subsys/<scriptname> The etc/rc.d/rc file was looking for the lock file when it tried to execute scripts from the symlinks marked with K*. Without that file, the system doesn't know that the "service" is "running".
Can a service script put inside init.d be called at startup and shutdown?
1,496,804,509,000
I have a /etc/rc.d/S11 link to a /etc/init.d file that is trying to set a bash variable of the file system type of a given blkid entry. root@OpenWrt:/# blkid /dev/mmcblk1p3 /dev/mmcblk1p3: UUID="77111d8a-feb7-470c-a489-ffa0e5415c4c" TYPE="f2fs" root@OpenWrt:/# I attempted to tack a awk onto the command root@OpenWrt:/...
I had to delay init until the blk device was available. Put in a while true loop to keep checking for it so I could mknod it.
Reading filesystem type at boot into BASH variable
1,496,804,509,000
I would like to launch a ssh reverse tunnel on system launch. The following line let's me establish the tunnel fine - but I end up being logged into server which I don't want, especially not from an init script. /usr/bin/autossh -M 22222 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /path/to/my/key.k...
What you're looking for is the -N option. From SSH's man page: -N Do not execute a remote command. This is useful for just for‐ warding ports. Your full command would be: /usr/bin/autossh -M 22222 -f -N -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /path/to/my/key.key -R ppp...
launch reverse tunnel with autossh on bootup in Ubuntu
1,496,804,509,000
I am running debian Jessie. During startup I want to read some user input. This is done by a custom script in /etc/init.d/ and symlinks in the runlevel dirs. Now I want kdm, which is started by another init script, to be started only after my custom script is finished. I cloud achieve this by adding something like wh...
Since you're using initscripts, the right way to defer kdm until your custom script has finished is to declare a dependency from kdm on your custom script, in the LSB header: # Required-Start: ... yourscript in the kdm initscript, and # Provides: yourscript in your custom initscript. To avoid the changes to the kdm ...
Delay an init script until another process is finished?
1,496,804,509,000
I added a script execution command to my rc.local but forgot to run it in a separate tty. The script has an infinite loop and has hung my tty1. Ctrl-C does not do anything and I don't have another bash login that would allow me to kill the script. Is there a keyboard command that will start a bash login? Is there any...
As rc.local is the last script that is run before the tty's are respawned by /bin/mingetty, therefore, the tty terminals will not be available to log into. However, networking and sshd will be running so just ssh to the host and kill the process as the root user.
Change to rc.local causing hang on tty1
1,496,804,509,000
Most unix servers do have services defined as init scripts, on linux in: /etc/init.d and on hp-ux in: /sbin/init.d. However, what if I just want a single command to be executed when machine boots? I could write a service init script for that purpose, but that seems to me too complicated for just one command, which lau...
If you are using a System V or BSD-like init, you can add a line in /etc/rc.local with the command. I suggest you background it (using &) so that it does not block further startup. If you are using systemd, be aware that it does not read /etc/rc.local by default. You can either write a service to execute /etc/rc.local...
Run a single command at the start of the machine
1,496,804,509,000
I am using SUSE Linux Enterprise Server 11 (x86_64) as VM Ware virtual machine (that was cloned). Not sure why but network card cannot be configured via yast2. If I go to edit and hit enter Yast will go back to "Control Center". Also in yast2 I can see that the card is "not connected". No idea what it means though. Bu...
On SuSE, you can configure the network manually via files in /etc/sysconfig/network. Create a file called /etc/sysconfig/network/ifcfg-eth1 containing STARTMODE=onboot BOOTPROTO=static IPADDR=10.0.0.xxx NETMASK=255.255.255.0 BROADCAST=10.0.0.255 The default route needs to be set in /etc/sysconfig/network/routes. defa...
Need to configure network card manually after each reboot
1,496,804,509,000
I have to tune my laptop's keyboard behaviour by lowering its brightness timeout, so I placed a one-line command in a script file, executed at boot. Here is it: $ cat /usr/local/bin/boot-script.sh #!/bin/bash echo "10s" | sudo tee /sys/devices/platform/dell-laptop/leds/dell\:\:kbd_backlight/stop_timeout Unfortunat...
After some attempts, the only way I found to fix the issue is to force the loading of the related kernel module (dell_laptop in my case) early in the boot process. I am on Arch Linux, and I have achieved it by adding dell_laptop in the MODULES=() array in /etc/mkinitcpio.conf. Furthermore: as @MC68020 stated, the im...
Bash script error on boot
1,496,804,509,000
I wrote an LSB init script that can manage multiple instances of my daemon: rcfoo start starts all the instances (which are found in some /etc configuration file), rcfoo stop stops all the instances, rcfoo status displays the status of all instances, and rcfoo reload reloads updates the daemon with a changed configura...
I found two possible solutions: Write a "wrapper script" that accepts an instance parameter and a command parameter. Then the script has to search whether the instance requested is actually found in the configuration file in /etc. The script actually does provide start, stop, and reload, while the PID of the daemon ...
How to migrate a multi-instance LSB script to systemd?
1,496,804,509,000
The Setup I have a machine that is running OpenBSD, it has two SSDs in it: sd0 and sd1. I've setup each SSD with two partitions a and d. From there I've built two mirrors using bioctl: The first mirror is built from sd0a and sd1a ; this shows up as sd2 The second mirror is built from sd0d and sd1d ; this shows up as ...
So after a bit of digging and reading here's what I've found: rc.local and even rc.securelevel are called far too late in the rc scripts to be used to mount the rest of the file system. A quick grep through the rc scripts made it clear the encrypted softraid needs to be attached just before the "Check filesystems" cod...
Mounting Encrypted Softraid on OpenBSD
1,496,804,509,000
I am attempting to create a new EC2 instance and I am supplying user-data to the instance at create time. My user-data executes some bash commands that modify the parameters of a properties file for another application (myApplication). The intent is to modify the configuration of myApplication BEFORE it starts. myAppl...
I think you hit a systemd bug. (One that they thought was a good idea.) Specifically to improve boot speed on sysv scripts that are imported they are run in parallel UNLESS you configure LSB dependencies, which sysv init ignores. The way around this is to either convert both init scripts to be systemd scripts with sy...
Order of execution for cloud-init-local on AWS Linux
1,416,824,305,000
I need to run a /usr/sbin command in my init script, so there is a dependency for the /usr filesytem to be mounted. To resolve the dependency, I put $local_fs or boot.localfs (I also tried $remote_fs and $all) in the required-start field of init script header, but it does still mount the /usr filesystem and my comman...
I figured out the solution, it might just help others. The problem was that just adding the dependency of boot.localfs in my init script was not enough. After adding the dependency, one needs to run the insserv command (as insserv boot.myinitscript) to enable the init script that is changed and it automatically resolv...
Init script header not resolving dependency
1,416,824,305,000
I need to run a script before shutting down or rebooting my VPS running Debian 8,to keep count of network statistics.I tried adding the script directly to /etc/init.d and symlinking it in /etc/rc0.d and /etc/rc6.d, and adding to it the LSB header, making it like an actual service with start and stop and generating the...
This works for me as /etc/systemd/system/netstat.service: [Unit] Description=Save interface stats on shutdown [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/true ExecStop=/bin/sh -c '{ date; ip -s link; } >>/root/ipstat.log' [Install] WantedBy=multi-user.target Enable it with systemctl enable netstat. T...
Execute simple script before shutdown and reboot
1,416,824,305,000
I am using my laptop in several monitor configurations that do require xorg.conf (say, I am driving a T221 from my laptop) and it's very inconvenient to manually switch them. Is there something in /sys which tells me if something is plugged into a DVI connector? Or a utility or ...?
Note that this broke with the latest Arch Linux upgrade, however the directory /sys/class/drm/ contains all the video outputs. I use head -1 /sys/class/drm/card0-HDMI-A-3/modes to detect the existence of the 3840x2400 mode but one could just check /sys/class/drm/card0-HDMI-A-3/status for connected vs disconnected if t...
Detecting monitor on boot time?
1,416,824,305,000
So I am working on building minimal os using busybox. What I want is I want to run my .net program from BIOS. But I am not sure linux will run .net program or not, so to clear my path I am using C program instead of .net program. I am generating initrd.img file successfully. Now before generating initrd.img file. I wa...
Your script is failing because you don’t have gcc in your initrd. You should not ship hello.c in your initrd; you should build the program and ship that instead in your initrd. You should also specify the full path to your program when attempting to run it.
How to integrate C program with init file?
1,416,824,305,000
I'm trying to understand what goes on when I start up a linux server. My linux server has files /etc/rc2.d/S03cron, /etc/rc3.d/S03cron, /etc/rc4.d/S03cron, /etc/rc5.d/S03cron which should start the cron daemon 4 times. once at each of those run levels. why is there only one cron process on my system? did it try to sta...
This depends on what init system you are using. In some init systems — old Solaris or SunOS, I think, although it's been way too long — the runlevels are cumulative in the way you are expecting. In others, including every Linux that uses the runlevel concept that I've ever heard of, they're independent descriptions of...
Why do init scripts not run multiple times?
1,416,824,305,000
nvidia-settings -a [gpu:0]/GPUPowerMizerMode=1 now what is the easiest way to run this one bash line of code at startup??? I am running Gnome 3.14.
You can use gnome-session-properties in terminal or using Alt+F2. That opens up Startup Applications Preferences in my Linux Mint (could be different for your distro). Give a name for your command (optional) Write the bash code in Command option Add any comment (optional) Alternatively, you could give a command to exe...
I need to run a one line startup script under gnome and systemd
1,416,824,305,000
I have set my script to run using the /etc/init.d method. All works good. The problem is that my script does packet capturing and when it restarts the machine after say the crond is loaded then it loads this script of mine and the packet capture process I guess starting then and it halts from going further. Is there a...
If you would run the command that runs within your init.d script with '&' after the end of the command, it will become a background process, and the next services could start. If you want the script to run as the final step (it would still block if it does not background) of your boot process, you could run it through...
Similar method to /etc/init.d
1,416,824,305,000
Below is an init script which starts/stops a daemon. The daemon is unfortunately printing the parsed packet data (from /home/nuthan/program/server), a socket server written in perl, listening to a socket for tcp packets from a client. As soon as I start the service, the parsed data (print statements from /home/nuthan...
You are mixing three commands: deamon, perl and /home/nuthan/program/server without any quotes. Think about the following: How does each of them know, which of the parameters it should interpret? The syntax you used could probably only be correctly interpreted, if: deamon would treat everything after -18 to be the co...
Prevent init daemon echoing on TTY
1,416,824,305,000
I have a very simple SysVinit service in /etc/rc.d: #!/bin/bash PIDFILE="/var/run/test.pid" status() { if [ -f "$PIDFILE" ]; then echo 'Service running' return 1 fi return 0 } start() { if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")"; then echo 'Service already running' return 1 fi e...
It looks like Synology moved from classic SysVinit to upstart in DSM 6 or so, and then to systemd in DSM 7. Both init systems provide backward compatibility for classic SysVinit-style start/stop scripts, but there are some quirks you should be aware of. If you have DSM 7.0 or newer, then after installing the script yo...
Stop not called for init rc.d service
1,416,824,305,000
I'm on Debian 10 Buster. I can't figure out what's wrong with this init.d script? Sometimes it doesn't run at server shutdown. My MySQL error_log fills up with "Status information" when the server reboots due to SIGHUP. Here is a link describing this behavior: MySQL Server response to SIGHUP signals This init.d script...
why you dont try to use systemd to manage daemons, its easier and available since debian Jessie. /etc/systemd/system/servicemysql.service [Unit] Description=MySQL task DefaultDependencies=no Conflicts=reboot.target Before=poweroff.target halt.target shutdown.target Requires=poweroff.target [Service] Type=oneshot Exec...
Why does this init.d script sometimes not run at shutdown?
1,416,824,305,000
I am running a CentOS (Red Hat Enterprise Linux Server release 7.6 (Maipo)) instance on AWS. I need to add to my boot sequence execution of a rc.local script. How can I do that? I have looked in /ect/rc.d and tried to add the script to a default using systemctl. Nothing works. Can someone point me to a right direction...
There are at least three methods you can use as far as I see it. Using /etc/rc.d/rc.local: Make sure the file is executable or chmod u+x it. Add the commands / script to the end of the file. Using crontab: Run: crontab -e Then add a crontab line like so: @reboot /your/script/here a Userdata script: Since it's ...
Linux CentOS: run rc.local after boot
1,416,824,305,000
I need to run a script upon startup, which I understand needs to be done in the init.d folder. Now this script requires sudo permissions, it prompts the user for the sudo password when being run normally. Is it possible to have my startup script run with sudo permissions automatically granted? Do I need to give the u...
Normally, the system runs startup scripts with full root access by default, so you don't have to do anything. Note that the script location depends on which init package is used in your system. For classic SysVinit, the start-up scripts are usually located in /etc/init.d and symbolic links indicating their place in ...
Automatic sudo permissions for startup script
1,416,824,305,000
My shell script knowledge is a little shaky, but I want to run a daemon (Ubuntu 14.04) defined in /etc/init.d/unicorn, like so case "$1" in start) check_config check_app_root log_daemon_msg "Starting $DESC" $NAME || true if start-stop-daemon --start --quiet --oknodo --pidfile $PID --...
It looks like there are a few problem with what you are doing. --exec only takes one argument, however arguments can be passed at the end of start-stop-daemon following a --. The argument of --exec is also used as an identifier: start-stop-daemon checks to see if there is an instance running (this would make /bin/sh,...
When running a daemon, how do I execute a command from a given directory?
1,416,824,305,000
Suppose you have write access to a Linux system, with root rights, but no interactive shell. You can only write new files or overwrite existing files. Creation of (sub)directories is possible. It's possible to define file permissions. How would you create a ba(sh) script, to be run after or at system boot? edit: I do ...
That depends on what init setup the Linux system in question uses. All the more commonplace ones use text files (and lots of symbolic links) to determine what needs to be run at boot and in what order, whether that's a bash script for sysvinit or a systemd unit file or something for runit or upstart or whatnot. Figure...
Set script to be executed at/after boot, with only write permissions, but no shell access on the target
1,416,824,305,000
I am creating a mesh interface on my raspberry pi's, using the "standard" set of commands: iw dev wlan0 interface add mesh0 type mp ifdown wlan0 ifconfig mesh0 192.168.202.103 iw dev mesh0 mesh join mymesh I tried putting all of these commands in a .sh script in the /etc/init.d/ folder, but it gets me nowhere. Does i...
I've managed to do this by making a mesh.sh script containing: #!/bin/sh sleep 5 iw wlan0 interface add mesh0 type mp sleep 1 ifdown wlan0 sleep 1 ifconfig mesh0 ifconfig mesh0 192.168.202.106 iw mesh0 mesh join meshpi Then creating a file called meshboot in /etc/init.d/ containing: #!/bin/sh ### BEGIN INIT INFO # P...
Automatic mesh interface
1,416,824,305,000
I need to have a PHP file execute whenever the httpd service starts or restarts. I found that Systemd has a configuration setting called **ExecStartPost, which looks perfect for what I need to do. I updated the /etc/systemd/system/multi-user.target.wants/httpd.service file to reflect the following: [Unit] Description=...
You have in your unit file: PrivateTmp=true This means systemd will create a separate namespace for the unit's /tmp and /var/tmp directories. Remove the line to use the usual /tmp.
Configuring Systemd to execute extra script after httpd start/restart using ExecStartPost setting not working
1,416,824,305,000
I know, when we run application in shell for a large website, we'd better set ulimit for our shell, But most of the service is started by systemd/sysv. Do I need set the ulimit in the service script (/etc/init.d) ?
You would normally set the ulimit on the user the service runs as in something like /etc/security/limits.conf. For example, if the web service is running as www-data, you would add an entry for www-data to /etc/security/limits.conf setting the relevant limits. If the process runs as root then it's more complicated giv...
Do I need set ulimit for system services, such as nginx.service(systemd)/nginx(sysv)?
1,416,824,305,000
I am wondering why during service start up environment variables are not visible. To be more precise: I created service startup scrip according to LSB spec which starts some java process. For this purpose JAVA_HOME env variable is checked first. This env variable is set in /etc/profile.d/java.sh. That is probably not...
RC scripts are invoked as non-interactive shell scripts. Thus they do not read /etc/profile. Thus you have to explicitly define your variables in your script. Either directly in your script or use some (covering up) techniques lot of RC script use (main variables defined in /etc/sysconfig/$package). See how tomcat6 is...
Why env variable are not visible while starting a service
1,416,824,305,000
I am building minimal operating system using busybox.I am writing init file, I want to call script1.sh file from init file. Challenges I am facing are: After running init file it is showing ./script1.sh : not found In script1.sh it has wine command which calls .exe, I am not wine is supported by busybox. So how Can I...
Same as previously, specify the full path to your script. If that still doesn’t work, edit your question to include the script’s contents (at least its first line). Busybox doesn’t include Wine; if you need Wine, you’ll have to make it available separately. I take it you’re trying to run a .Net WPF program; there’s ...
How to execute wine command through busbox?
1,416,824,305,000
Using Ubuntu 16.04.6 LTS, it is not possible to call the service command to modify the status of any /etc/init/ services. The command starts but is stuck in execution. The services themselves are running still running and stopping though, based on their own configuration (start on, etc.) Scripts that are in /etc/init....
It turns out it was the instance not having enough RAM and stopping processes forcefully
Ubuntu "service" command stuck, can't reload services
1,295,035,247,000
It appears systemd is the hot new init system on the block, same as Upstart was a few years ago. What are the pros/cons for each? Also, how does each compare to other init systems?
2016 Update Most answers here are five years old so it's time for some updates. Ubuntu used to use upstart by default but they abandoned it last year in favor of systemd - see: Grab your pitchforks: Ubuntu to switch to systemd on Monday (The Register) Because of that there is a nice article Systemd for Upstart Users...
What are the pros/cons of Upstart and systemd?
1,295,035,247,000
I just switched to debian jessie, and most things run okay, including my graphical display manager wdm. The thing is, I just don't understand how this works. Obviously my /etc/init.d/wdm script is called, because when I put an early exit in there, wdm is not started. But when I alternatively rename the /etc/rc3.d dir...
chaos' answer is what some documentation says. But it's not what systemd actually does. (It's not what van Smoorenburg rc did, either. The van Smoorenburg rc most definitely did not ignore LSB headers, which insserv used to calculate static orderings, for starters.) The Freedesktop documentation, such as that "Inc...
How does systemd use /etc/init.d scripts?
1,295,035,247,000
I just want to know difference between in reboot init 6 shutdown -r now and which is the safest and the best?
There is no difference in them. Internally they do exactly the same thing: reboot uses the shutdown command (with the -r switch). The shutdown command used to kill all the running processes, unmount all the file systems and finally tells the kernel to issue the ACPI power command. The source can be found here. In old...
What is the difference between reboot , init 6 and shutdown -r now?
1,295,035,247,000
This may have more to do with detecting operating systems, but I specifically need the init system currently in use on the system. Fedora 15 and Ubuntu now use systemd, Ubuntu used to use Upstart (long time default until 15.04), while others use variations of System V. I have an application that I am writing to be a ...
For the second question, the answer is no and you should have a look at Resources for portable shell programming. As for the first part - first of all, you certainly have to be careful. I'd say perform several tests to make sure - because the fact that someone does have systemd (for ex.) installed, does not mean it is...
Detect init system using the shell
1,295,035,247,000
Is there a simple way to find out which initsystem is being used e.g by a recent Debian wheezy or Fedora system? I'm aware that Fedora 21 uses systemd initsystem but that is because I read that and because all relevant scripts/symlinks are stored in /etc/systemd/. However, I'm not sure about e.g Debian squeeze or Ce...
You can poke around the system to find indicators. One way is to check for the existence of three directories: /usr/lib/systemd tells you you're on a systemd based system. /usr/share/upstart is a pretty good indicator that you're on an Upstart-based system. /etc/init.d tells you the box has SysV init in its history ...
How to find out if a system uses SysV, Upstart or Systemd initsystem [duplicate]
1,295,035,247,000
I have a remote machine running Debian 8 (Jessie) with lightdm installed. I want it to start in no-GUI mode, but I don't want to remove all X-related stuff to still be able to run it though SSH with the -X parameter. So how to disable X server autostart without removing it? I tried systemctl stop lightdm, it stops the...
The disable didn't work because the Debian /etc/X11/default-display-manager logic is winding up overriding it. In order to make text boot the default under systemd (regardless of which distro, really): systemctl set-default multi-user.target To change back to booting to the GUI, systemctl set-default graphical.target...
How to disable X server autostart in Debian Jessie?
1,295,035,247,000
I have been studying the Linux kernel behaviour for quite some time now, and it's always been clear to me that: When a process dies, all its children are given back to the init process (PID 1) until they eventually die. However, recently, someone with much more experience than me with the kernel told me that: When ...
When a process exits, all its children also die (unless you use NOHUP in which case they get back to init). This is wrong. Dead wrong. The person saying that was either mistaken, or confused a particular situation with the the general case. There are two ways in which the death of a process can indirectly cause the ...
Is there any UNIX variant on which a child process dies with its parent?
1,295,035,247,000
I am creating a linux distro and now I need an init program. I can code in c really well and I know quite a bit about linux (not much but I've been using arch linux for development for 4 years), so I thought I should try writing my own basic init script in C. I was just wondering, what tasks does init do to set the sy...
System 5 init will tell you only a small part of the story. There's a sort of myopia that affects the Linux world. People think that they use a thing called "System 5 init", and that is both what is traditional and the best place to start. Neither is in fact the case. Tradition isn't in fact what such people say it ...
What exactly does init do?
1,295,035,247,000
Can root kill init process (the process with pid 1)? What would be its consequences?
By default, no, that's not allowed. Under Linux (from man 2 kill): The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally. Pid 1 (init) can decide to allow its...
Can root kill init process?
1,295,035,247,000
I'm wanting to understand the Linux init process better in order to netboot a system over ceph rather than nfs. In the process I've come across two forms of switching root. One called switch_root, and the other called pivot_root. These scripts being run from an in memory filesystem (initramfs) obtained via tftp usin...
I found a wonderful explanation here. However, let me try to put in a shorter format of what I understood in the answer. Shorter Version While the system boots, it needs an early userspace. It can be achieved using either initramfs or initrd. initrd is loaded into ramdisk which is an actual FILE SYSTEM. initramfs is...
When would you use pivot_root over switch_root?
1,295,035,247,000
Between the recent "Why does 'kill -9 0' end my console session" and "How to get a kernel panic" questions, I got a bur under my saddle and tried kill -9 1 on a mostly up-to-date Arch linux laptop. I did it as user ID "root". I fully expected some kind of crash or panic or shutdown, but nothing happened. I did kill ...
From man 2 kill: The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally. That is, it is possible for init to do whatever it likes upon receiving SIGKILL (including exit...
How does systemd survive a kill -9?
1,295,035,247,000
I have always learned that the init process is the ancestor of all processes. Why does process 2 have a PPID of 0? $ ps -ef | head -n 3 UID PID PPID C STIME TTY TIME CMD root 1 0 0 May14 ? 00:00:01 /sbin/init root 2 0 0 May14 ? 00:00:00 [kthreadd]
First, “ancestor” isn't the same thing as “parent”. The ancestor can be the parent's parent's … parent's parent, and the kernel only keeps track of one level. However, when a process dies, its children are adopted by init, so you will see a lot of processes whose parent is 1 on a typical system. Modern Linux systems a...
init process: ancestor of all processes?
1,295,035,247,000
In UNIX, when a parent process disappears, I thought that all child processes reset init as their parent. Is this not correct all the time? Are there any exceptions?
Moving my comment to an answer.... I don't believe there are exceptions. Found this "sometimes the parent process is killed before its child is killed. In this case, the "parent of all processes," init process, becomes the new PPID (parent process ID). Sometime these processes are called orphan process." source Simil...
New parent process when the parent process dies
1,295,035,247,000
Installing a new system using a GPT partitioned disk dedicated to a single partition, ext4 formatted, extlinux (version 4.05) as bootloader, Ubuntu Core version 13.10 amd64 as rootfs, and Ubuntu linux-image-3.11.0-18-generic as kernel, and extlinux-update to generate bootloader configuration. The result after reboot (...
Modify your kernel boot parameter by setting the root=/dev/sdaX option. sdaX would be your / or root partition. Upon booting the next time, you will see that your initramfs tries to mount the partition before trying to access /etc/fstab and mounting the file systems. See question "Does initramfs use /etc/fstab?" for ...
How to fix boot into initramfs prompt and "mount: can't read '/etc/fstab': No such file or directory" and "No init found"?
1,295,035,247,000
I created the following service, amos.service, and it needs to run as amos (member of the amos group) [Unit] Description=AMOS Service After=network.target [Service] User=amos Group=amos Type=simple WorkingDirectory=/usr/share/amos ExecStart=/usr/share/amos/amos_service.sh start ExecStop=/usr/share/amos/amos_service.s...
Use systemd: To show the problem use journalctl -xe after you started the service. You don't need a bash script, put this in your service file: ExecStart=/usr/share/amos/run_amos.sh There is no need for ExecStop, systemd will stop all child processes. You can view the output with journalctl -u amos.service.
Running a systemd service as a user other than root!
1,295,035,247,000
Transmission is intermittently hanging on my NAS. If I send SIGTERM, it doesn't disappear from the process list and a <defunct> label appears next to it. If I send a SIGKILL, it still doesn't disappear and I can't terminate the parent because the parent is init. The only way I can get rid of the process and restart...
You cannot kill a <defunct> process (also known as zombie process) as it is already dead. The system keeps zombie processes for the parent to collect the exit status. If the parent does not collect the exit status then the zombie processes will stay around forever. The only way to get rid of those zombie processes are...
How can I kill a <defunct> process whose parent is init?
1,295,035,247,000
Not much to put here in the body.
Processes need to have a parent (PPID). The kernel, despite not being a real process, is nevertheless handcrafting some real processes like at least init, and is giving itself the process ID 0. Depending on the OS it might or might not be displayed as a process in ps output but is always displayed as a PPID: eg on Lin...
If computers start counting at 0, why does the init process have a pid of 1?
1,295,035,247,000
As I understand it, a zombie process has died but still exists as a placeholder in the process table until its parent (or init if the zombie is itself an orphan) checks its exit status. And my understanding of orphan processes is they are processes that are still alive and running but whose parent has died. Since a zo...
As I understand it, a zombie process has died but still exists as a placeholder in the process table until its parent (or init if the zombie is itself an orphan) checks its exit status. Correct. And my understanding of orphan processes is they are processes that are still alive and running but whose parent has died...
Can a zombie have orphans? Will the orphan children be disturbed by reaping the zombie?
1,295,035,247,000
I need one process run before log in to system. How to run it like services? how do I make services in Linux? In Ubuntu and Fedora? The service is customized tomcat
To run a service without or before logging in to the system (i.e. "on boot"), you will need to create a startup script and add it to the boot sequence. There's three parts to a service script: start, stop and restart. The basic structure of a service script is: #!/bin/bash # RETVAL=0; start() { echo “Starting <Serv...
Start tomcat at startup with administrative privileges
1,295,035,247,000
I'm trying to debug an init script on a Linux system; I'm trying to pass init=/bin/sh to the kernel to make it start sh without starting init so I can run through the init sequence manually. What I've found is that the kernel is starting init anyway. During bootup, one of the printk messages is the command line, and t...
Looking at Linux kernel source, I see that if the file /init exists, the kernel will always attempt to run it on the assumption that it's doing a ramdisk boot. Check your system to see if /init exists, if it does, then that's probably your problem.
What can make passing init=/path/to/program to the kernel not start program as init?