Shell -- tipserver of the daemon

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.