Adventure 1
Adventure 1
Adventure 1
Adventure 1
「每天早上 8 点,AI 自动给你发一条 Telegram:『早上好! 🌞 今天的学习计划:复习数学第 3 章、练习 Python 循环。加油!」 💪'"
Adventure 1
Adventure 1
Adventure 1
Adventure 1
Adventure 1
Adventure 1
* * * * * command
│ │ │ │ │
│ │ │ │ └─ Day of week (0-7, Sun=0 or 7)
│ │ │ └─── Month (1-12)
│ │ └───── Day of month (1-31)
│ └─────── Hour (0-23)
└───────── Minute (0-59)Adventure 1
0 = 分钟为 0(整点)8 = 小时为 8(上午 8 点)* = 任意月内日期* = 任意月份* = 任意星期几0 8 * * * echo "Good morning!"Adventure 1
0 21 * * 1-5 echo "Time for bed!"1-5,表示周一(1)到周五(5)。周末自动跳过。注意 21 在 24 小时制里就是晚上 9 点。Adventure 1
1,15 表示「就在这几天」。非常适合半月一次的工资,或者每月零花钱。
Adventure 1
*/5 * * * * echo "Status check"*/5 意思是「每 N 个单位」。监控系统、检查新消息、保持服务平稳,全都用得上。*/10 表示每 10 分钟一次,或者 */2 每 2 分钟一次。Adventure 1
*/15 * * * *Adventure 1
Adventure 1
nano (最简单)或者 vim (如果你已经熟练了)。Adventure 1
* * * * * echo "Cron works! $(date)" >> ~/cron-test.logCtrl+X,然后 Y,然后 Enter.Adventure 1
cat ~/cron-test.logAdventure 1
~ 指向你的家目录Adventure 1
Adventure 1
vim ~/morning-briefing.sh#!/bin/bash
openclaw agent --message "Send my owner a good morning message with today's date, an inspirational quote, and a reminder about today's study tasks."#!/bin/bash)告诉 Linux 这是一个 bash 脚本。第二行用自然语言给 OpenClaw 发指令。Adventure 1
chmod +x ~/morning-briefing.sh+x 这个参数的意思是「让它可执行」。现在你的脚本就能像其他程序一样跑起来了。bash ~/morning-briefing.shAdventure 1
student1 替换成你的用户名):0 8 * * * /home/student1/morning-briefing.shAdventure 1
Adventure 1
Adventure 1
0 21 * * * 每晚 9 点,AI 问你:「今天你学了什么?」0 7 * * 1 每周一早上 7 点,收到本周目标和精神补给0 * * * * 每小时一次,检查系统是否运转良好0 */2 * * * 白天每 2 小时一次:「该喝水啦。」Adventure 1
Adventure 1
Adventure 1
Adventure 1
Adventure 1
8 * * * * (一小时跑 8 次!)0 8 * * * (早上 8 点跑一次)morning-briefing.sh/home/student1/morning-briefing.shchmod +x your-script.sh>> logfile.txt 把输出留下来,方便排查Adventure 1
bash your-script.sh 能不能直接跑通?跑不通就先把脚本本身修好ls -l your-script.sh 看看是不是有 x 权限位/var/log/syslog 找 cron 的执行记录echo "Starting..." 便于追踪Adventure 1
Adventure 1
*/10 * * * * 是什么意思?Adventure 1
crontab -e 打开 cron 编辑器——所有定时任务都在这里定义30 15 * * * (记住:15 在 24 小时制里就是下午 3 点,30 是分钟)chmod +x filename.sh 添加可执行权限Adventure 1
Adventure 1
Adventure 1
Adventure 1