Script Method for Linux Startup and Shutdown

Source: Internet
Author: User

1. Create a script under/etc/rc. d/init. d/to comply with the service script standard;

For example:

VI/etc/rc. d/init. d/GFS

#! /Bin/bash
#

Case "$1" in
Restart)
Echo "umount/Data"
Umount/Data
Echo "Mount/Data"
Touch/var/lock/subsys/GFS
Mount-T gfs2/dev/gfsvg/GFS/Data
;;
Start)
Echo "Mount/Data"
Touch/var/lock/subsys/GFS
Mount-T gfs2/dev/gfsvg/GFS/Data
;;
Stop)
Echo "umount/Data"
Umount/Data
;;
*)
Echo "Usage: $0 {restart | START | stop }"
Exit 1
Esac
Exit 1

2. Modify the execution script permission

Chown-r root/etc/rc. d/init. d/GFS
Chmod 700/etc/rc. d/init. d/GFS

3. Create a symbolic connection for startup (S stands for START, K stands for START, K stands for kill, and stands for close. Number indicates the order of startup)

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc0.d/s60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc1.d/s60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc2.d/s60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc3.d/s60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc4.d/s60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc5.d/s60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc6.d/s60gfs

4. Create shutdown and execute

1) empty file in/var/lock/subsys

Touch/var/lock/subsys/GFS

2) create a shutdown symbolic connection

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc0.d/k60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc1.d/k60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc2.d/k60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc3.d/k60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc4.d/k60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc5.d/k60gfs

Ln-S/etc/rc. d/init. d/GFS/etc/rc. d/rc6.d/k60gfs

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.