Log routine operations on Linux at work

Take the Tomcat program as an example

1. View the directory where Tomcat is located

(or view the Tomcat process)

ps -ef|grep tomcat
Copy the code

You can view the tomcat directory and process ID.

root 7010 1 0 Apr19 ? X x XXXXX etc. (the number in front is the port

2. Close the tomcat

The id is the id of the process that tomcat is running

kill -9 id
Copy the code

3. Start Tomcat (go to the bin directory of Tomcat).

./startup.sh
Copy the code

4. Disable Tomcat (preferably run the kill port command to prevent tomcat from being disabled).

 ./shutdown.sh
Copy the code

5. Start Tomcat and view real-time logs

# Go to the tomcat directory sh bin/startup.sh; tail -f logs/catalina.outCopy the code

6. View the first 1000 lines of the log

head -n 1000 logs/catalina.out
Copy the code

7. View the next 1000 lines of the log

tail -n 1000 logs/catalina.out
Copy the code

8. The vi editor

Vi server.config In common mode I -> Edit mode :q -> Exit the vi editor :q! -> Forcibly exit the editor :wq -> Save the configuration and exit the editing modeCopy the code