Files
kenaito-kopsc/README.log.md
T
odboy 400812d114 feat: 新增 file/svc/archive/sys/log/fw 分组并扩充 net、proc
- file:findbig 按大小、findrecent 按修改时间、findname 按名称查找文件
- svc:systemctl / launchctl / sc 统一接口,status、enable、disable、logs
- archive:按扩展名自动识别格式并解压,支持 tar.gz/tgz/tar.bz2/tar.xz/tar/zip/gz
- sysinfo:OS、CPU、内存、磁盘一览
- log:journalctl / log show / wevtutil 搜索关键字与查看最近日志
- fw:ufw / firewalld / iptables / ALF / netsh 统一接口,status、allow、deny
- net 新增 ping、trace(mtr 优先)、dns(dig 优先)、curl HTTP 诊断
- proc 新增 topmem、topcpu、killname
- 危险操作(svc enable/disable、proc killname、fw allow/deny)需 --yes 确认
- 注册表、executor 派发表、cli 分组说明与 README 同步更新
2026-11-02 22:42:18 +08:00

54 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# log - 系统日志
在系统日志中搜索关键字或查看最近日志,不用记 `journalctl` / `log show` / `wevtutil` 的区别。
## 命令
| 命令 | 作用 |
| --- | --- |
| `kopsc log search <关键字> [选项]` | 在系统日志中搜索关键字 |
| `kopsc log last [行数] [-u 服务]` | 查看最近的系统日志 |
## 示例
```bash
# 搜索最近 1 小时包含 "error" 的日志
kopsc log search "error" --since 1h
# 搜索 nginx 服务的日志
kopsc log search "502" -u nginx
# 查看最近 50 行系统日志(默认)
kopsc log last
# 查看最近 100 行
kopsc log last 100
# 查看 nginx 服务的最近日志
kopsc log last -u nginx
```
## 选项
### log search
| 选项 | 说明 |
| --- | --- |
| `--since` | 时间范围,如 `1h`、`30m`、`2h30m` |
| `-u` / `--unit` | 限定服务名 |
| `-n` / `--lines` | 最大行数(默认 100) |
### log last
| 选项 | 说明 |
| --- | --- |
| `-n` / `--lines` | 行数(默认 50) |
| `-u` / `--unit` | 限定服务名 |
## 平台实现
| 操作 | Linux | macOS | Windows |
| --- | --- | --- | --- |
| search | `journalctl --grep` | `log show --predicate` | `wevtutil` + 过滤 |
| last | `journalctl -n` | `log show --last` | `wevtutil /c:` |