CronJob
A comprehensive sysops toolkit for scanning, monitoring, reporting, and maintaining scheduled job operations. CronJob provides 18+ commands for tracking job events, performing health checks, managing backups, benchmarking performance, and exporting operational data in multiple formats.
Commands
| Command | Description |
|---|
| INLINECODE0 | Record a scan entry — run without args to view recent scan entries |
| INLINECODE1 |
Record a monitoring observation — run without args to view recent entries |
|
cronjob report <input> | Log a report entry — run without args to view recent reports |
|
cronjob alert <input> | Record an alert — run without args to view recent alerts |
|
cronjob top <input> | Log a top-level event — run without args to view recent entries |
|
cronjob usage <input> | Track usage data — run without args to view recent usage entries |
|
cronjob check <input> | Record a check result — run without args to view recent checks |
|
cronjob fix <input> | Log a fix action — run without args to view recent fixes |
|
cronjob cleanup <input> | Record a cleanup operation — run without args to view recent cleanups |
|
cronjob backup <input> | Log a backup event — run without args to view recent backups |
|
cronjob restore <input> | Record a restore operation — run without args to view recent restores |
|
cronjob log <input> | Add a general log entry — run without args to view recent log entries |
|
cronjob benchmark <input> | Record a benchmark result — run without args to view recent benchmarks |
|
cronjob compare <input> | Log a comparison — run without args to view recent comparisons |
|
cronjob stats | Display summary statistics across all log categories |
|
cronjob export <fmt> | Export all data to a file (formats:
json,
csv,
txt) |
|
cronjob search <term> | Search across all log files for a keyword |
|
cronjob recent | Show the 20 most recent activity entries from the history log |
|
cronjob status | Health check — shows version, data directory, entry count, disk usage |
|
cronjob help | Display available commands and usage information |
|
cronjob version | Print current version (v2.0.0) |
Each data command (scan, monitor, report, etc.) works in two modes:
- - With arguments: Records the input with a timestamp into its dedicated log file
- Without arguments: Displays the 20 most recent entries from that category
Data Storage
All data is stored locally in plain-text log files:
- - Location: INLINECODE24
- Format: Each entry is saved as
YYYY-MM-DD HH:MM|<value> in per-category .log files - History: All operations are additionally logged to
history.log with timestamps - Export: The
export command can generate JSON, CSV, or TXT files from all log data - No cloud sync — everything stays on your machine
Requirements
- - Bash 4.0+ (uses
set -euo pipefail) - Standard Unix utilities:
date, wc, du, head, tail, grep, basename, INLINECODE37 - No external dependencies, no API keys, no network access required
- Works on Linux and macOS
When to Use
- 1. Cron job monitoring — Track the execution status of scheduled jobs, log failures, and set up alerts for review
- Job audit trail — Record scan, check, and report entries to maintain a complete history of job operations
- Backup & restore logging — Log backup and restore events with timestamps so you always know what happened and when
- Performance benchmarking — Record benchmark results for scheduled tasks and compare them over time to spot regressions
- Operational data export — Export all collected logs in JSON, CSV, or TXT format for dashboards, compliance, or further analysis
Examples
CODEBLOCK0
Configuration
Set CRONJOB_DIR to change the data directory. Default: ~/.local/share/cronjob/
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
CronJob
一个全面的系统运维工具包,用于扫描、监控、报告和维护定时任务操作。CronJob提供18+个命令,用于追踪任务事件、执行健康检查、管理备份、基准测试性能,以及以多种格式导出操作数据。
命令
| 命令 | 描述 |
|---|
| cronjob scan <输入> | 记录扫描条目 — 无参数运行可查看最近的扫描条目 |
| cronjob monitor <输入> |
记录监控观察结果 — 无参数运行可查看最近的条目 |
| cronjob report <输入> | 记录报告条目 — 无参数运行可查看最近的报告 |
| cronjob alert <输入> | 记录警报 — 无参数运行可查看最近的警报 |
| cronjob top <输入> | 记录顶级事件 — 无参数运行可查看最近的条目 |
| cronjob usage <输入> | 追踪使用数据 — 无参数运行可查看最近的使用条目 |
| cronjob check <输入> | 记录检查结果 — 无参数运行可查看最近的检查 |
| cronjob fix <输入> | 记录修复操作 — 无参数运行可查看最近的修复 |
| cronjob cleanup <输入> | 记录清理操作 — 无参数运行可查看最近的清理 |
| cronjob backup <输入> | 记录备份事件 — 无参数运行可查看最近的备份 |
| cronjob restore <输入> | 记录恢复操作 — 无参数运行可查看最近的恢复 |
| cronjob log <输入> | 添加通用日志条目 — 无参数运行可查看最近的日志条目 |
| cronjob benchmark <输入> | 记录基准测试结果 — 无参数运行可查看最近的基准测试 |
| cronjob compare <输入> | 记录比较结果 — 无参数运行可查看最近的比较 |
| cronjob stats | 显示所有日志类别的汇总统计信息 |
| cronjob export <格式> | 将所有数据导出到文件(格式:json、csv、txt) |
| cronjob search <关键词> | 在所有日志文件中搜索关键词 |
| cronjob recent | 显示历史日志中最近的20条活动条目 |
| cronjob status | 健康检查 — 显示版本、数据目录、条目数量、磁盘使用情况 |
| cronjob help | 显示可用命令和使用信息 |
| cronjob version | 打印当前版本(v2.0.0) |
每个数据命令(scan、monitor、report等)有两种工作模式:
- - 带参数:将输入内容连同时间戳记录到专用日志文件中
- 无参数:显示该类别中最近的20条条目
数据存储
所有数据本地存储在纯文本日志文件中:
- - 位置:~/.local/share/cronjob/
- 格式:每条条目以YYYY-MM-DD HH:MM|<值>格式保存到按类别划分的.log文件中
- 历史记录:所有操作还会额外记录到history.log中,并带有时间戳
- 导出:export命令可从所有日志数据生成JSON、CSV或TXT文件
- 无云同步 — 所有数据保留在本地机器上
系统要求
- - Bash 4.0+(使用set -euo pipefail)
- 标准Unix工具:date、wc、du、head、tail、grep、basename、cat
- 无需外部依赖、无需API密钥、无需网络访问
- 适用于Linux和macOS
使用场景
- 1. 定时任务监控 — 追踪定时任务的执行状态,记录失败情况,并设置警报以供审查
- 任务审计追踪 — 记录扫描、检查和报告条目,维护任务操作的完整历史记录
- 备份与恢复日志记录 — 记录带时间戳的备份和恢复事件,确保始终了解发生了什么以及何时发生
- 性能基准测试 — 记录定时任务的基准测试结果,并随时间进行比较以发现性能退化
- 操作数据导出 — 以JSON、CSV或TXT格式导出所有收集的日志,用于仪表盘、合规性或进一步分析
示例
bash
记录定时任务健康扫描
cronjob scan 今天所有12个定时任务均成功运行
记录监控观察结果
cronjob monitor 备份任务耗时45分钟,比平时长3倍
记录失败任务的警报
cronjob alert 每日报告定时任务在03:00失败 — 退出代码1
记录已执行的修复操作
cronjob fix 将备份任务的超时时间从30分钟增加到90分钟
查看所有类别的汇总统计信息
cronjob stats
将所有数据导出为CSV用于电子表格分析
cronjob export csv
搜索与特定任务相关的条目
cronjob search backup-job
快速健康检查
cronjob status
查看最近的20条活动条目
cronjob recent
配置
设置CRONJOB_DIR可更改数据目录。默认值:~/.local/share/cronjob/
由BytesAgain提供技术支持 | bytesagain.com | hello@bytesagain.com