This topic describes how to obtain custom environment variables from an application.
Before you perform high-risk operations, such as modifying the configurations or data of an instance, we recommend that you check the disaster recovery and fault tolerance capabilities of the instance to ensure data security.
Before you modify the configurations or data of an instance, such as an Elastic Compute Service (ECS) instance or an ApsaraDB RDS instance, we recommend that you create snapshots or enable the backup feature for the instance. For example, you can enable the log backup feature for an ApsaraDB RDS instance.
If you have granted permissions on sensitive information or submitted sensitive information in the Alibaba Cloud Management Console, we recommend that you modify the sensitive information at the earliest opportunity. Sensitive information includes usernames and passwords.
Log on to the application server and run the following command to switch to the admin account:
su - admin
~/.bash_profilefile to add the custom environment variables that you want to obtain. Then, save the configurations and exit from the code editor.
Run the following command to execute the script:
After you execute the script, call methods such as
System.getenv()to obtain the custom environment variables from the application code.Important
After the application code is modified, restart the application to make the configurations take effect.