[Practice OK] check the Environment variables when a process (program) is started in Linux

Source: Internet
Author: User
[Practice OK] in Linux, check the context of environment variables when the process (program) is started. because of the recent installation of jira In Linux, a Chinese plug-in is installed. once it is set to start, it is in English, and after the terminal restarts again, it seems that the plug-in takes effect, and it is restored to normal Chinese... [practice OK] in Linux, check the context of environment variables when the process (program) is started. because of the recent installation of jira In Linux, a Chinese plug-in is installed. once it is set to start, it is in English, and after the terminal restarts again, it seems that the plug-in takes effect and it is restored to a normal Chinese interface. first, I think this involves an environment variable problem, some variables cannot be found when I use service jira start to set the service to start. for example, if the home directory of java cannot be obtained, the system prompts that no variables can be found. therefore, I added the java environment variable to boot and started OK, but in English, I know little about English, but still want to use Chinese, otherwise the plug-in will be equivalent to Bai 'an. To this end, you need to find out the difference between the two environment variables, how to view the environment variables of a running program two ways: Method 1: Get the process number to get the environment variables: root@192.168.98.128: ~ # Ps aux | grep jiraroot 2341 25.3 55.0 758544 384956 pts/0 get the PID: 2341 view the environment variable command of the process as follows: ps eww-p 2341 // Obtain a large string of environment variables method 2, view the environment information in the proc directory and separate the environment variable tr '\ 0' \ n' </proc/2341/environ after the diff distinction, two differences are obtained: (1) TERM = linux TERM = xterm // This may be because when I set xterm when using SecureCRT, this variable is brought in (in: session Options-> terminal-> simulation-> terminal: xterm) (2) LANG = en_US.UTF-8 LANG = zh_CN.UTF-8 // Here is a terminal coding problem: there is a difference between en_US and zh_CN. the problem may be located here. Now let's do this: the export LANG = zh_CN.UTF-8 places this line in the first line of the startup command:/etc/init. d/jira. Export LANG = zh_CN.UTF-8nohup/usr/local/jira/bin/shutdown. sh>/dev/null 2> & 1 & | ~ 26 usleep 100000 | ~ 27 nohup/usr/local/jira/bin/startup. sh>/dev/null 2> & 1 & after the above modification, it was successful. I guess it is correct. ----------------------------------------------------- Appendix: is the shell script executed by nohup unable to pass the configured global variables to the script for use? Export LOGFILE # export as an environment variable to be 123. sh process uses nohup 123.sh ========================================== ===================== of course, you do not need to export, as long as the source script is used, the global variable is set to the current shell process. if you want it to become an environment variable so that it can be used by subsequent shell sub-processes, it will be export. I was thinking: why didn't I read the value of this file when jira was started? Strange: Is your jira version too low. Vi/etc/sysconfig/i18n matches different environment variables at startup and terminal running to the same one. this problem is solved. ---------------------------------------------------------------- The following additional information: Why is the difference between the environment variables after startup and the environment variables when the terminal is started: first, it is clear that in linux, both command line input and system settings are shell. (The Startup setting is in (/etc/init. d/rcS), the shell that configures the system environment variable is located in/etc/profile, and the shell that configures the user-level environment variable is ~ /. Bashrc-execute each time the terminal is started; or ~ /. Bash_profile-executed when the session starts ). Add the library path to the environment variable LD_LIB_PATH. Note: 1. you can use the emacs command to edit the command line. for example, ctrl-B indicates that you are stepping back. ctrl-a indicates that the cursor is moved to the beginning. 2. you can enter several commands for execution in sequence: command1; command2 or command1 & command2 (execute command2 when command1 is executed successfully ). 3. background running and program debug output redirection: after running a program on the terminal, you can use ctrl-z to suspend and enter the bg command to run the program in the background (of course, you can also directly add & in the background &). Command &>/dev/null & the terminal will no longer output debugging information. 4. output redirection: (1) multiple command redirection, | for example, | grep text | less, and (2) redirect to the file command> file (replace the file content with the command output) or command> file (directly add the command output to the end of the file ). 5. change the prompt by setting PS1 = "something. 6. Use alias newcommand = "oldcommand" to set the alias of the command. 1.2. 6410 boot start and environment variable settings 1. add the boot startup program to the shell file/etc/init. d/rcS file 2. add environment variables to the/etc/profile File (PATH and LD_LIBRARY_PATH)
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.