1.Linux find 命令
将当前目录及其子目录下所有文件后缀为 .log 的文件列出来:
# find . -name "*.log"
2.Linux tail 命令
查询倒数 100 行文件,并监听实时写入
tail -100f application.log
要显示 notes.log 文件的最后 10 行,请输入以下命令:
tail notes.log # 默认显示最后 10 行
tail -n 100 /etc/cron #显示最后100行数据
3.Linux grep 命令
3.1 查询所有的java进程 ps -ef | grep java
3.2 在 application.log 中查找 username
grep username application.log
cat application.log | grep -i username
3.3 同时在两个文件中查找 ERROR
grep ERROR web_info.log web_error.log
4.Linux kill命令
# kill 12345 杀死进程
# kill -9 123456 彻底杀死进程
5.Linux nohup 命令
nohup java -jar demo-0.0.1-SNAPSHOT.jar >nohup.out 2>&1 &
2>&1 解释:
将标准错误 2 重定向到标准输出 &1 ,标准输出 &1 再被重定向输入到 runoob.log 文件中。
- 0 – stdin (standard input,标准输入)
- 1 – stdout (standard output,标准输出)
- 2 – stderr (standard error,标准错误输出)