How to make scripts executable anywhere

Hello everyone, I'm Kaka不期速成,日拱一卒

In the previous article "In trouble, the generation environment performed DDL operations" , in order to prevent SQL blocking caused by online DDL, a third-party plug-in was used pt-online-schema-change.

When using this plugin to modify table data, many parameters need to be added, such as database name, table name, database address, database password and other parameters.

Then the plug-in needs to execute a series of parameters optimized into a script, so the question is, how to make this script executable anywhere?

In the previous article, Ka Ka placed the executed script in the following position. Next, let's see what methods can make this script executable anywhere.

Dead MySQL series

1. Add the script path to the .bashrc file

When bash runs, the .bahsrc file is first loaded, so you can directly add the script path to be executed to this file

Then you have to know where the .bashrc file is! The location is in the root directory of the current user, and you can see this file after executing cd ~

Then put your script path in this file and add the last line of codeexport PATH="/script:$PATH"

Finally, use sourcethe command to make our changes take effect

source ~/.bashrc

Let's try adding a bash field to the evt_sms table directly in the root directory. See the figure below to know that our configuration is successful.

2. Add the script path to the .profile file

The file path is in etc/profile

export PATH="$PATH:$HOME/script"add at the end of the file

This method needs to exit the terminal to take effect

3. How to use the soft chain

Copy the written script to /usr/local/bin

Just add a soft linkln -s /usr/local/bin/pt.sh /usr/bin/pt.sh

Then you can execute the pt.sh script anywhere

4. Summary

This article briefly talks to you about two ways to make your script executable anywhere, and you can use one of them.

But you need to understand the way of implementation, because everyone likes to deal with different ways, when you encounter this kind of script, you need to know where it is configured, and then you can modify it

5. Recommended reading

Open the door of order by and take a look at "Deadly Kick MySQL Series Twelve"

Heavy blockade, so that you can't get a single piece of data "Deadly Kick MySQL Series Thirteen"

Trouble, the generation environment performed the DDL operation "Deadly Kick MySQL Series Fourteen"

Talk about the locking rules of MySQL "Deadly Kick MySQL Series Fifteen"

Persistence in learning, perseverance in writing, perseverance in sharing are the beliefs that Kaka has upheld since her career. I hope the article can bring you a little help on the huge Internet, I am Kaka, see you in the next issue.

Guess you like

Origin blog.csdn.net/fangkang7/article/details/121781148