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