Tag Info

Hot answers tagged

24

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


19

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.


16

The correct way to disable and upstart service, is create a XX.override file, echo 'manual' > /etc/init/mysqld.override That way the upstart service will not get started automatically


16

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 ...


14

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 ...


12

You can disable services by running the following command : sudo update-rc.d -f <service name> disable


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 ...


10

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

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

(you might have to install the package ip on openwrt (v12 / attitude adjustment) ifconfig/netstat etc. are considered deprecated, so you should use (as root) ss -nlput | grep sshd to show the TCP/UDP sockets on which a running program which contains the string sshd is listening to -nno port to name resolution -lonly listening sockets -pshow processes ...


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

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() ...


7

There are many ways, i'd suggest using the cron sepcial string @reboot. $ crontab -e @reboot /path/to/my/command.sh


7

With command & Your process will be killed by a SIGHUP signal when the parent dies. Sysadmins have access to some workarounds, 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. ...


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

command should not contain multiple words. This is the cause of the [ error you see. You should set any flags separately. Also, you should use pytivo_user to set the running uid, and not daemon -u. See the rc.subr(8) man page for all these magic variables. Also, you should let the rc subsystem know that pytivo is a Python script so that it can find the ...


6

The difference between running a program/process as a daemon and forking it to the background using the ampersand is basically related to ownership. Most often, the parent process of a daemon is the init process (the very first process to be started on a Unix system), the daemon being a child of that process means that it is not under your direct control as ...


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

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 ...


5

Guessing from the Gentoo Wiki, editing NTPD_OPTS in /etc/conf.d/ntpd probably does the trick (regardless of the question if -g is advisable, no idea).


5

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


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

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). ...


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

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 ...


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 ...



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