T
ToolPrime

Cron Expression for Daily at Midnight

Run a cron job once per day at midnight using 0 0 * * *. The standard daily schedule for backups, cleanups, and reporting.

Expression

0 0 * * *

At 00:00 every day

Use Cases

Code Examples

Crontab

# At 00:00 every day
0 0 * * * /path/to/your/script.sh

GitHub Actions

name: Scheduled Job
on:
  schedule:
    - cron: '0 0 * * *'
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: echo "Running Daily at Midnight"

systemd Timer

[Unit]
Description=Daily at Midnight timer

[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true

[Install]
WantedBy=timers.target

node-cron (Node.js)

import cron from 'node-cron'

// At 00:00 every day
cron.schedule('0 0 * * *', () => {
  console.log('Running Daily at Midnight')
})

Spring (@Scheduled, Java)

// At 00:00 every day
@Scheduled(cron = "0 0 0 * * *")
public void run() {
    // your task
}

Spring cron has 6 fields (a leading seconds field), so a 0 is prepended to the standard 5-field expression.

Tips

Frequently Asked Questions

Is @daily the same as 0 0 * * *?

Yes, @daily is a shorthand supported by most cron implementations (including crontab and systemd) that is equivalent to 0 0 * * *.

Does midnight mean UTC or local time?

In standard cron, midnight means the server local time. In cloud services like GitHub Actions, you can specify the timezone. Always check your environment.

Related Cron Expressions

Related Tools