Linux Registration Custom TFTPD Service __linux

Source: Internet
Author: User
Tags usleep
The Linux boot service is to use service + TFTPD, the (Ubuntu) service will go to find/ETC/INIT.D under the launch program, service +TFTPD can run.

Chkconfig is used to add the service to the boot list.

Chkconfig--add tftpd
chkconfig--list chkconfig tftpd on/off
Writing shell Scripts
#!/bin/bash #description: tftpd #chkconfig: 2345-Bayi set-e #及时返回错误 exec_path=/software/tftp-1.0/exec=tftpd daemon=/sof TWARE/TFTP-1.0/TFTPD Pid_file=/var/run/tftpd.pid #. /etc/rc.d/init.d/functions IF [!-X $EXEC _path/$EXEC];  
       Then echo "ERROR: $DAEMON not found" Exit 1 fi Stop () {echo "stoping $EXEC ..." PS aux | grep "$DAEMON" | Kill-9 ' awk ' {print $} ' >/dev/null 2>&1 # 0 input 1 Output 2 error output/dev/null empty device file & representation equivalent to, background execution rm-f $PID _file # usleep echo "shutting down $EXEC: [OK]" status} status () {pid= ' ps aux | g Rep "$DAEMON" |grep-v grep | awk ' {print $} ' # grep-v grep is the elimination of inclusion grep, that is, itself, the last process. The reverse single quotation mark executes the command and assigns a value #echo $PID if (("$PID")); Then #判断 $PID is true, TFTPD starts echo "TFTPD start/running, Process $PID" Else echo "tftpd stop/waiting" fi} start ( {echo "Starting $EXEC ..." $DAEMON >/dev/null & pidof $EXEC > $PID _fILE # usleep echo "Starting $EXEC: [OK]" status} restart () {stop  
    Start} case "in Start" start;;  
    stop) stop;;  
    restart) restart;;  
    Status) # Status-p $PID _file $DAEMON Status   *) echo "Usage:service $EXEC {start|stop|restart|status}" Exit 1 Esac exit $?
Registration Service
chmod tftpd
CP./TFTPD/ETC/INIT.D
chkconfig--add tftpd chkconfig
--list
Delete Service
Chkconfig--del TFTPD
Chkconfig--del TFTPD
In addition: Process directory/proc/process ID;

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.