How To Install daemonize on CentOS 8

daemonize is Run a command as a Unix daemon

Introduction

In this tutorial we learn how to install daemonize on CentOS 8.

What is daemonize

daemonize runs a command as a Unix daemon. As defined in W. Richard Stevens’ 1990 book, Unix Network Programming (Addison-Wesley, 1990), a daemon is “a process that executes ‘in the background’ (i.e., without an associated terminal or login shell) either waiting for some event to occur, or waiting to perform some specified task on a periodic basis.” Upon startup, a typical daemon program will - Close all open file descriptors (especially standard input, standard output and standard error) - Change its working directory to the root filesystem, to ensure that it doesn\u2019t tie up another filesystem and prevent it from being unmounted - Reset its umask value - Run in the background (i.e., fork) - Disassociate from its process group (usually a shell), to insulate itself from signals (such as HUP) sent to the process group - Ignore all terminal I/O signals - Disassociate from the control terminal (and take steps not to reacquire one) - Handle any SIGCLD signals Most programs that are designed to be run as daemons do that work for themselves. However, you\u2019ll occasionally run across one that does not. When you must run a daemon program that does not properly make itself into a true Unix daemon, you can use daemonize to force it to run as a true daemon.

We can use yum or dnf to install daemonize on CentOS 8. In this tutorial we discuss both methods but you only need to choose one of method to install daemonize.

Install daemonize on CentOS 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install daemonize using dnf by running the following command:

sudo dnf -y install daemonize

Install daemonize on CentOS 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install daemonize using yum by running the following command:

sudo yum -y install daemonize

How To Uninstall daemonize on CentOS 8

To uninstall only the daemonize package we can use the following command:

sudo dnf remove daemonize

daemonize Package Contents on CentOS 8

/usr/lib/.build-id
/usr/lib/.build-id/24
/usr/lib/.build-id/24/8906b5a70e422ab35e8874a7ff4675cd5a3d1e
/usr/sbin/daemonize
/usr/share/doc/daemonize
/usr/share/doc/daemonize/CHANGELOG.md
/usr/share/doc/daemonize/LICENSE.md
/usr/share/doc/daemonize/README.md
/usr/share/man/man1/daemonize.1.gz

References

Summary

In this tutorial we learn how to install daemonize on CentOS 8 using yum and dnf.