Shell Script Summary

Source: Internet
Author: User

1. Variables

A: Define variable a=1, only valid for your shell process

B: Define the variable export b=1, which will take effect on your shell process and its child processes

C: Variables defined in the script.sh script, when source script.sh is in the current shell login process, the variables defined in the script will also enter the currently logged in process.

Note: You can use Pstree to view the hierarchy of processes.

For example:

Remote execution launches the ZK script when using SSH telnet to 65.5 in 65.3 to start the ZK show execution succeeds. But to 65.5 view did not start ZK as follows:

Cause: This script runs remotely to start ZK, but when the script is remotely part of a stand-alone session, which is the end of the remote session, it kills the ZK child process. And ZK's start-up relies on Java.

So you need to modify the command to:

SSH [email protected] $i "source/etc/profile;bash/app/zk/zookeeper-3.4.5/bin/zkserver.sh start"

2. Global scripting

When you want a script to execute in each directory, you need to configure it to the $path directory and grant execute permissions.

For example:

You want to execute the startzk.sh custom script in any directory, as follows:

A: View $path

B: Place the custom script in any of the above directories and give Execute permissions

C: This script can be executed in any other directory

Shell Script Summary

Related Article

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.