Tag Info

Hot answers tagged

28

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


20

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


20

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.


17

You can disable services by running the following command: sudo update-rc.d -f <service name> disable Man page excerpt: When run with the disable [ S|2|3|4|5 ] options, update-rc.d modifies existing runlevel links for the script /etc/init.d/name by renaming start links to stop links with a sequence number equal to the ...


17

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


16

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


13

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


12

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


12

Shall I use another way to do so that would be considered "Good Practice"? Unless you have strong, irrefutable reasons otherwise, you should just use the NTP package that comes with your GNU/Linux distribution. The standard NTP daemon has taken years to mature and come with sophisticated features such as slowing or speeding up your system's clock ...


12

Is it a good practice to run a daemon under a non-root user account? Yes, and this is common. For instance, Apache start as root and then forks new process as www-data (by default). As said before, if your program is hacked (ex: code injection), the attacker will not gain a root access, but will be limited to the privileges you gave to this specific ...


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

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


8

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


8

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


7

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


7

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


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


7

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


7

The notion of daemon is attached to processes, not files. For this reason, there is no sense in "finding daemons on the filesystem". Just to make the notion a little clearer : a program is an executable file (visible in the output of ls) ; a process is an instance of that program (visible in the output of ps). Now, if we use the information I can gave in my ...


6

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


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

run the command in this way: ($HOME/.dropbox-dist/dropboxd &)& this will detach the process from tha actual terminal and put it in real background. You will still have to start it back up manually after a reboot, though.


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


6

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


6

start-stop-daemon --start --pidfile "$pid" doesn't write to the pid file unless --make-pidfile (-m) is specified. Without --make-pidfile it is up to the program being launched to create it. Also for --make-pidfile to work, the process being launched can't daemonize itself (via a fork), as then start-stop-daemon won't know what PID it should put in the file. ...


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

One important difference is that HAL is deprecated.



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