如何设置Cron Tab从xx:x8起每10分钟执行?及表达式可行性疑问
Nice question! Let's break this down clearly so you can get your script running exactly when you want it to.
Why */10-2 Won't Work
First off, the expression */10-2 won't achieve what you're aiming for. Cron's minute field syntax doesn't support combining a step value (*/10) with a range suffix like -2—this is invalid and will either be ignored or lead to unexpected behavior. The */10 part alone tells cron to run every 10 minutes starting at xx:00, which is why you're seeing it trigger at xx:00, xx:10, etc.
Correct Ways to Schedule Your Script
There are two straightforward, reliable ways to set up your desired schedule:
Method 1: Explicit Minute List
The most intuitive approach is to list all the exact minutes you want the script to run. For your use case, that means specifying every 10th minute starting at 8:
8,18,28,38,48,58 * * * * /path/to/your/script.sh
This tells cron to trigger at xx:08, xx:18, xx:28, and so on, every hour. It's easy to read and leaves no room for ambiguity.
Method 2: Start Time + Step Interval
Cron supports a "start value / step" syntax that lets you define a starting minute and then repeat every N minutes. For your schedule, this looks like:
8/10 * * * * /path/to/your/script.sh
Here, 8/10 means: "Start at minute 8, then run every 10 minutes after that." Cron automatically calculates the subsequent trigger times (18, 28, 38, 48, 58) and wraps around to the next hour's 8th minute once it hits 58. This is a cleaner, more concise option if you don't want to list all minutes manually.
Quick Cron Syntax Reminder
To avoid confusion in the future, here's a quick recap of valid minute field patterns:
- Single value:
8→ runs only at xx:08 - Range:
8-18→ runs every minute from xx:08 to xx:18 - Step from 0:
*/10→ runs every 10 minutes starting at xx:00 - Step from a custom start:
8/10→ runs every 10 minutes starting at xx:08
内容的提问来源于stack exchange,提问作者David Magrefty

