Python daemonize
The process of daemonization in a Linux system always goes through the same process regardless of the development language. In general, the ID of the parent process is 1 (init process id) through a double fork processing. Also, since the daemon needs to operate regardless of input/output, it dedirects stdout, stderr, and stdin to /dev/null. Here is a very simple Python code. It simply displays Hello World in the loop statement. The only part I care about is adding code for handling the termination signal. Normal Python Program import time import os , sys import signal ''' For Smooth Closing ''' def stop (sig, frame): print( 'Process Exit' ) sys . exit( 0 ) signal . signal(signal . SIGINT, stop) signal . signal(signal . SIGTERM, stop) while True : time . sleep( 1 ) print( 'Hello World' ) <normal.py> If you run the code, you may see this screen output. [root @ gcloud-seoul-a093086b769c683771dee9c71...