How does Spring Boot cron differ from Linux cron?
Linux crontab uses 5 fields (min hour dom month dow). Spring Boot's @Scheduled(cron) uses 6 fields (sec min hour dom month dow) — with an extra 'seconds' field at the start. This is the most common gotcha.
What's the difference between ? and *?
* matches every value in that field. ? means 'no specific value' and can only be used in the day-of-month (DOM) and day-of-week (DOW) fields. When you specify one, set the other to ? to avoid ambiguity.
How do I run every 5 minutes?
Use the step syntax /: 0 */5 * * * ? fires every 5 minutes (at 0, 5, 10…55). The 0 in the seconds field ensures it fires at exact minute boundaries.
How do I run only on weekdays?
Set the DOW field to MON-FRI (or 1-5) and the DOM field to ?. Example: 0 0 9 ? * MON-FRI runs every weekday at 9 AM. Spring Boot supports SUN/MON/TUE/WED/THU/FRI/SAT abbreviations.
What annotations are needed to activate a scheduled task?
Two steps: ① add @EnableScheduling to your main class; ② add @Scheduled(cron = "...") to the method. The method's class must be a Spring-managed bean (@Component, @Service, etc.).