Cron Atlas

Quartz error @daily and other shortcuts

Unexpected character: @

java.lang.RuntimeException: CronExpression '@daily' is invalid.
Caused by: java.text.ParseException: Unexpected character: @

Message produced by running the expression through org.quartz.CronExpression from Quartz 2.5.2.

What it means

Shortcuts like @daily, @hourly and @weekly come from Unix cron. Quartz has none of them, so the @ is the first thing it can’t read. Write the fields out instead.

Rejected expressions and their fixes

Each expression opens in the tester. The message under a rejected one is what Quartz 2.5.2 printed for it.

  1. Rejected@hourlyUnexpected character: @
    Use
    0 0 * * * ?Every hour, on the hour.

    On the hour, every hour.

  2. Rejected@dailyUnexpected character: @
    Use
    0 0 0 * * ?At 00:00.

    Midnight every day.

  3. Rejected@weeklyUnexpected character: @
    Use
    0 0 0 ? * SUNAt 00:00, on Sundays.

    Midnight at the start of Sunday, as cron’s @weekly is.

  4. Rejected@monthlyUnexpected character: @
    Use
    0 0 0 1 * ?At 00:00, on the 1st of the month.

    Midnight on the 1st.

  5. Rejected@yearlyUnexpected character: @
    Use
    0 0 0 1 1 ?At 00:00, on the 1st of the month, in January.

    Midnight on 1 January.

Questions

What is @daily in Quartz?
0 0 0 * * ?: second 0, minute 0, hour 0, every day of the month, with day of week left as ?.
Does Kubernetes accept @daily?
Yes. The parser behind Kubernetes CronJobs accepts @yearly, @monthly, @weekly, @daily and @hourly. Quartz, EventBridge, GitHub Actions and Azure do not.

Other Quartz errors

Reference