Linux Boot Start program detailed

Source: Internet
Author: User

record This thing is last completed, today to add a new folder, a moment to forget how to do, because there are several ways, at least I know three ways, here to record a previous practice, feel the simplest:Operating system: CentOS-5.2 target: Automatically mount the shared directory of Windows in LAN on Boot

First, root permission editor/etc/rc.d/rc.local

Shell Code
    1. Su
    2. cd/etc/rc.d/
    3. VI rc.local

second, in this file plus the script you want to execute, the full contents are as follows:

Shell Code
  1. #!/bin/sh
  2. #
  3. # This script is executed *after* all and the other init scripts.
  4. # can put your own initialization stuff in here if you don ' t
  5. # want to does the full Sys V style init stuff.
  6. Touch/var/lock/subsys/local
  7. Mount//192.168. 0.3/data2-1/mnt/data2-1-o username=un,password=123
  8. Mount//192.168. 0.3/data2-2/mnt/data2-2-o username=un,password=123
  9. Mount//192.168. 0.3/data2-3/mnt/data2-3-o username=un,password=123
  10. Mount//192.168. 0.3/data2-4/mnt/data2-4-o username=un,password=123
  11. Mount//192.168. 0.3/data2-5/mnt/data2-4-o username=un,password=123

Hint: The practice here is very immature, I hope not, it is best to write a script file here to call, the structure is clearer, but note that the command to execute as a parameter to the SU.

In addition review a VI editing command-copy YYP

Third, although the fix, or to add

When Linux starts, it automatically executes the initialization program in the/ETC/RC.D directory, so we can put the startup task in that directory, in the following ways:

Programme one:

Relatively simple, is the above approach, the/etc/rc.d/directory of the initialization program a lot, rc.local is done after all initialization, so it is appropriate to tamper here.

Scenario Two:

INIT.D directories are executable programs, they are actually service scripts, written in a certain format, Linux at startup will be executed automatically, similar to the services under Windows.

1, write the following script simpletest:

Shell Code
  1. #!/bin/bash
  2. #chkconfig:2345 05--Specify at which levels to perform,0 generally refer to shutdown,6 refer to reboot, and others for normal startup. 80 is the priority of the boot,05 is the priority level of the shutdown
  3. #description: simple Example Service
  4. retval=0
  5. Start () {#启动服务的入口函数
  6. echo "Simple example service is started ..."
  7. }
  8. Stop () {#关闭服务的入口函数
  9. echo "Simple example service is stoped ..."
  10. }
  11. #使用case选择
  12. Case $1 in
  13. Start
  14. Start
  15. ;;
  16. Stop
  17. Stop
  18. ;;
  19. *)
  20. echo "Error choice!  Please input start or stop ";;
  21. Esac
  22. Exit $RETVA

3, run chmod +x/etc/rc.d/init.d/simpletest, so that it can be directly executed

4, run Chkconfig--add simpletest, add the service to the configuration

5, run Chkconfig--list simpletest, you can view the status of the service process

Scenario three, the purpose is to mount the shared directory, so you can add in the/etc/fstab

192.168.0.3/data2-1/mnt/data2-1 NFS username=un,password=123 0 0

Very embarrassed, scenario two although the script can run

#./simpletest Start
Simple example service is started ...

But I showed up in the 4th step.

# chkconfig--add simpletest
Error reading information in SimpleTest Service: no file or directory
No further resolution sorry.

Linux Boot Start program detailed

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.