Linux in startup.sh and shutdown.sh

Source: Internet
Author: User

Recently, a server-side program was written with a socket, listening on 1024 ports , detecting requests from clients, and writing start-up and stop scripts in Linux:

In Eclipse Java write a program, right-click the export generated Runnable JAR file and then Socketserver.jar upload to the server.

1. Start startup.sh

# ----------------------------------------------------# Start Script forThe socekt server#----------------------------------------------------PS-ef |grep Socketserver.jar |grep-v grepif[$?-eq 0];then Echo' Socket server is running! 'Elsenetstat-APN |grep 1024if[$?-eq 0];then pid_1024= $ (echo ' netstat-apn |grep 1024x768 | awk ' {print $NF} ' |awk-f '/' {print '} '') Kill $PID _1024 Fi echo"Startup Socket Server:"nohup Java-jar Socketserver.jar &fi

2. Start shutdown.sh

#----------------------------------------------------for---------------------------- -------------------------ef | grep Socketserver | grep-v grepif [$?-eq 0 ];then  pid_1024=$ (Echo ' netstat-apn |grep 1024x768 | awk ' {print $NF } ' |awk-f '/' {print '} '  )   kill  $PID _1024     else' not found Socket pid! ' fi

at the same time, set the file operation permissions: chmod 777 startup.sh, chmod 777 shutdown.sh

The last execution./startup.sh can be started!

Linux in startup.sh and shutdown.sh

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.