Files
crontab-ui/README.md
T
JianMiauandClaude Fable 5 6bc6a8758d 新增 macOS 版 crontab-ui
摘要:
網頁版排程與程序管理面板(macOS 原版),操作系統 crontab 並整合 PM2、Node.js 程序、Docker 與 log 檢視。

說明:
- Crontab 頁籤直接讀寫系統 crontab,任務由系統 cron 執行
- 監聽 port 以 lsof 偵測、程序清單用 ps aux、結束程序用 kill
- 附 README 說明安裝、PM2 常駐與運作方式

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 12:32:43 +08:00

61 lines
2.0 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.
# Crontab UI (macOS)
網頁版的排程與程序管理面板,直接操作 macOS 的系統 `crontab`,並整合 PM2、Node.js 程序、Docker 與 log 檢視。
單一 Node.js 伺服器(Express+ 單一 HTML 前端,無框架、無建置步驟。
> Windows 移植版請見 `master` 分支。
## 功能
| 頁籤 | 說明 |
|---|---|
| ⏰ Crontab | 讀寫**系統 crontab**`crontab -l` / `crontab <file>`),支援新增、編輯、啟用/停用、刪除、任務備註(label) |
| 🟢 PM2 | 列出 PM2 程序(狀態、PID、CPU、記憶體、重啟次數、監聽 port),可啟動/停止/重啟/刪除 |
| 🟡 Node.js | 列出系統上所有 node / bun 程序(`ps aux`),可結束程序(`kill -15` / `kill -9` |
| 🐳 Docker | 列出容器並可啟動/停止/重啟(需安裝 Docker) |
| 📋 Log | 瀏覽 log 目錄下的 `.log` 檔案,支援 tail 與自動刷新 |
## 安裝與執行
需求:Node.js 18+、macOS(或其他有 crontab 的 Unix 系統)
```bash
npm install
node server.js
```
開啟 <http://localhost:3789>
### 用 PM2 背景常駐(建議)
```bash
npm install -g pm2
pm2 start server.js --name crontab-ui
pm2 save
pm2 startup # 依照輸出的指令設定開機自動啟動(launchd)
```
## 環境變數
| 變數 | 預設值 | 說明 |
|---|---|---|
| `PORT` | `3789` | 網頁伺服器 port |
| `LOG_DIR` | `/Volumes/HDD/Claude/logs` | Log 頁籤讀取的目錄 |
## 運作方式
- 排程任務由**系統 cron** 執行,本工具只負責讀寫 crontab 內容;伺服器停止不影響排程執行
- 任務上方緊鄰的 `#` 註解行會被視為該任務的備註(label),在 UI 中一併顯示與編輯
- 停用任務 = 在該行前面加 `#`,啟用 = 移除
- 監聽 port 以 `lsof -iTCP -sTCP:LISTEN` 偵測後對應到 PM2 程序
## 專案結構
```
crontab-ui/
├── server.js # Express APIcrontab / pm2 / ps / docker / logs
└── public/
└── index.html # 前端(單檔,無建置)
```