Tag Info

Hot answers tagged

21

If you're running the daemon from your own account, start it at boot time with Cron. Run crontab -e to edit your crontab file and add the line @reboot ~/.dropbox-dist/dropboxd


18

The traditional way of daemonizing is: fork() setsid() close(0) /* and /dev/null as fd 0, 1 and 2 */ close(1) close(2) fork() This ensures that the process is no longer in the same process group as the terminal and thus won't be killed together with it. The IO redirection is to make output not appear on the terminal.


14

For a daemon, what you want is a process that has no tie to anything. At the very least, you want it to be in its own session, not be attached to a terminal, not have any file descriptor inherited from the parent open to anything, not have a parent caring for you (other than init) have the current directory in / so as not to prevent a umount... To detach ...


13

Using lsof (as root): # lsof -i -n -P COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 3028 root 3u IPv4 7072 0t0 TCP *:22 (LISTEN) sshd 3028 root 4u IPv6 7074 0t0 TCP *:22 (LISTEN) iproute2's ss can do this, too (as root): # ss -lp State Recv-Q Send-Q Local Address:Port ...


11

This is done for 2 reasons. Security and auditing. From a security perspective each service is put into it's own "silo" so that it can be given access to only the resources it needs on the system. These resources can be diskspace, access to files, or allocations of RAM or CPU. Additionally each service can be walled off from every other service so that ...


9

You don't modify the /etc/init.d/skeleton file. You copy it to a new file /etc/init.d/mamoudservice (replace mamoudservice with a more suitable name) and then you edit that new file appropriately. Then you add a symlink from /etc/rc2.d/S99mamoudservice to /etc/init.d/mamoudservice etc. Use e.g. /bin/bash -vx /etc/init.d/mamoudservice start to ...


9

There are several ways a process might be killed because of a dying terminal. The first way is that the terminal driver in the kernel sends a SIGHUP signal to the controlling process for which the terminal is the controlling terminal. In most cases, the controlling process is the shell that is initially started in the terminal, and its controlling terminal ...


9

A background-job (ie. started with &) still has it's stdin, stdout and stderr connected to the terminal it was started in. It may suddenly write (eg. error-messages) to the terminal ("disturbing" the job in the foreground) or pause waiting for input from the keyboard (you must first put it in the foreground). You may of course redirect stdout and ...


9

In POSIX, every running process has three User IDs (UIDs) associated with it; the real UID, which identifies the user who launched the process, the effective UID, which is used to determine what resources the process can access, and the saved Set-User-ID (SUID), which is the effective UID the process had when it started (at the point of the last exec() ...


6

Neither. If you want to have it behave properly like a real daemon you should place it using the init system - /etc/init.d ( and make appropriate runlevel links in the appropriate /etc/rc.X folders ) Run a search or have a look at something like this: http://serverfault.com/questions/204695/comprehensive-guide-to-init-d-scripts


6

With command & Your process will be killed by a SIGHUP signal when the parent dies. Sysadmins have access to some workaround, though. On a bash system, you can use: (trap '' HUP; command) & This opens a subshell, traps the HUP signal with an empty handler and ampersand/forks it. Output might still get redirected to the wrong tty. Or get lost. ...


5

Android uses a single Zygote process that forks to start a new application. This optimization is possible because all Android applications start in the same environment; there is very little to do (mainly set the user and load the application code) to launch an application. This optimization is effective because there is little to do, especially since the ...


5

Sounds like it's reading from standard input (stdin). Try adding the -d (Do not attempt to read from stdin) option to netcat. Or redirect on the command line: netcat localhost 1099 <&- | bash loop.sh & You may also want to use nohup to make sure that it won't be adversely affected when/if you exit that shell before it stops.


5

What does update-rc.d to do with Arch ? that's for debian based distros. A sample script, put it in /etc/rc.d/XX and make it executable, and edit /etc/rc.conf, push the name of the service into DAEMONS array #!/bin/sh . /etc/rc.conf . /etc/rc.d/functions case "$1" in stop) stat_busy "Stopping XX" command_to_exec ...


5

@warl0ck has it right; wanted to add that this information is documented quite well in the Upstart documentation: http://upstart.ubuntu.com/cookbook/#disabling-a-job-from-automatically-starting Specifically: With Upstart 1.3, you can make use of override files and the manual stanza to achieve the same result in a simpler manner [27]: # echo ...


5

There are various tools to do this (of which, other than daemontools and perp, I don't have much experience with): daemontools is more or less the "classic" implementation that spurned most of the other modern implementations supervisord minit s6 runit The one we have come to like at my workplace is perp, which was the best featured for our ...


5

They are commonly found in /tmp or a subdirectory thereof. Note that everything in /tmp is subject to erasure at shutdown -- not that it necessarily is erased, just beware that it can be, so if you use that, check if you have to create your subdirectory each time. You will want to use a subdirectory if you want to restrict access via permissions, since ...


5

Basically you have two options: use a cron job with @reboot time specification (see crontab(1) man-page for details) start it by the init system. For BSD/SysV init style this means adding a script somewhere to be run in the desired runlevel, for systemd this involves creating a unit file and requiring it by the desired target, First solution is better ...


5

systemd provides systemd-tmpfiles for this exact purpose. The systemd-tmpfiles service handles the creation, cleaning and removal of volatile and temporary files and directories which usually reside in directories such as /run or /tmp. The configuration of systemd-tmpfiles is described in the manual page of tmpfiles.d1. Create a systemd-tmpfiles ...


4

by default NFS is enabled you can remove packages: apt-get --purge remove nfs-kernel-server nfs-common portmap or stop services temporary: /etc/init.d/portmap stop /etc/init.d/nfs-kernel-server stop or stop them permanently: service portmap stop service nfs-kernel-server stop


4

If the server allows public key authentication, put the public key of the connecting client to the server's ~/.ssh/authorized_keys file. Use ssh-keygen on the client, the create a key pair. You may also use the ssh-copy-id script to copy the public key to the server. On key generation, you may omit the passphrase, so you won't be asked for it. Be sure to ...


4

systemd allows users to run their own systemd instances to manage private daemons. If you already have systemd installed, all you have to do is launch systemd --user and manage your services by running systemctl --user. User services will be searched for in ~/.config/systemd/user. By default systemd will kill user services on logout (as you requested). ...


4

You could hack it into MySQL itself (e.g. OpenSSH's sshd does this), yet that's a bit too hardcore and very dirty (problems with updates etc.) You can do this in a wrapper or in the init script - the score should be inherited (and in a wrapper you would probably want to do exec mysqld "$@" anyway). Use cgroups - it will give you a bit more flexibility and ...


4

This is possible in Ubuntu using Upstart and the oom score configuration option. oom score Linux has an "Out of Memory" killer facility. [...] Normally the OOM killer regards all processes equally, this stanza advises the kernel to treat this job differently. The "adjustment" value provided to this stanza may be an integer value from ...


4

The difference is in the will continue to run outputting log messages to the console part. A daemon is a long running process that doesn't have any reference to the console that launched it originally. Removing the reference takes a couple of additional steps (closing the original input and output file descriptors) known as 'detaching'.


4

For starting at boot time add a line to your users crontab file (using crontab -e): @reboot /path/to/your/script with parameters The actual contents of that script vary with your needs. It might just start the daemon, or it might start a somewhat more intelligent agent that you pass a configuration. That way you can have your service automatically ...


4

First, Openbox depends on Xorg so it needs to and will be installed as a dependency. Second, you can set up your machine to boot only into a shell which is the standard for a minimal Debian install. Then you can run startx (if Xorg isinstalled) in that console and this command will start your X11. To start an Openbox session with startx you have to edit ...


3

The netcat process is reading from its standard input. Since it's connected to the terminal, the process group that netcat is in (i.e. the pipeline) must run in the foreground. You need to plug something at the beginning of the pipeline that will send the input that the server expects. For example, with an HTTP server, you might have something like netcat ...


3

1) I'm afraid that it's the latter. But don't feel bad, most people trip over it. 2+3) The only ones that would have a chance of working are 5 and 8. The startup scripts and cron have no idea of your login session, so there's no way they could point remind or gmessage in the right direction. And 5 didn't work because the ampersand at the end is a feature of ...


3

JVM startup time is quite slow, and incurs a heavy toll on scripting . . . huge optimization for java process startup time. The other answers answer the question with respect to generic app startup, which are useful considerations. But seems your primary question is Java application startup performance re overhead of starting a jvm. This has also been ...



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