Daemon shell -- tipserver 1: You can directly turn off the terminal and run it in the background. 2. You can query the service status. 3. You can regularly start the program to run. (example: Start) 4: You can avoid repeated tipserver startup at runtime #! /Bin/sh run_main_programer () {while truedoif ["$ date_hour" = '17'] thenas = 'date + '% Y % m % d _ % H % M % s' sh. /control_sh.sh> log/control_sh _ $. logsleep 3600 fisleep 300date_hour = 'date + '% h'' done} myself = 'echo $0 | sed's/^ \. /// g'' if [$ #-eq 0] then echo "Unknown command option" echo "Usage :: "echo" $ myself start | stop | status "exitfi case" x $1 "inxstart) # list of threads running in the current background thread = 'ps-ef | grep-v grep | grep-w "$ myself" | grep "start" | awk '{print $2 }' '# Only this thread runs if ["$ thread" = "$"] thennohup sh $ myself start>/dev/null & sleep 3 echo "The $ myself have been started. "else # obtain the parent thread number father_thread = 'ps-ef | grep-v grep | grep" $ myself "| grep" start "| grep" $ "| awk '{print $3} ''# The parent thread of the current thread has if ['ps-ef | grep-v grep | grep" $ myself "| grep" start "| grep" $ father_thread" | wc-l '-eq 2] thenrun_main_programerfiecho "The $ myself is running. "fi; xstop) thread = 'ps-ef | grep-v grep | grep "$ myself" | grep "start" | awk '{print $2} ''if [-n" $ thread"] thenkill-9 $ {thread} 2>/dev/nullfiecho "The $ myself have been stoped. "; xstatus) thread = 'ps-ef | grep-v grep | grep "$ myself" | grep "start" | awk '{print $2} ''if [-n" $ thread"] thenecho "The $ myself is running. "elseecho" The $ myself is not running. "fi; *) echo 'error parameter. 'esac