Run Bi-Annual Tasks on Jan 1 and Jul 1 | CronBase

cron expression Standard
$ 0 0 1 1,7 *

At midnight on the opening day of January and July.

This cron expression schedules a job to run twice a year at midnight on the first day of January and July. It is commonly used for bi-annual maintenance, semi-annual financial reporting, long-term database archiving, and compliance auditing tasks that only need execution every six months.

Minute
0
Hour
0
Day of Month
1
Month
1,7
Day of Week
*
How it works

Next 5 Runs

  • in 159d 3h
  • in 340d 3h
  • in 524d 3h
  • in 706d 3h
  • in 890d 3h

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# Production-grade script to register the bi-annual cron job
# and execute a backup/cleanup task safely with logging.
set -euo pipefail

LOG_FILE="/var/log/biannual-job.log"
exec >> "$LOG_FILE" 2>&1

echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] Starting bi-annual maintenance task..."

# Real-world task: Rotate long-term archives
if tar -czf /backups/archive-$(date +%Y-%m).tar.gz /data/audit; then
    echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] Task completed successfully."
else
    echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] ERROR: Task failed." >&2
    exit 1
fi
Setup notes

Add this script to the system crontab using crontab -e with the line 0 0 1 1,7 * /path/to/script.sh to ensure it executes at midnight on January 1st and July 1st.

Last verified:

Partner BetterStack

Monitor this schedule in production

Get alerted the moment this cron job fails, is late, or doesn't run. BetterStack tracks execution, duration, and output — no infrastructure required.

Platform Equivalents

AWS EventBridge

Standard cron expressions often need conversion for AWS EventBridge schedules.

EventBridge Rule
cron(0 0 1 1,7 ? *)

Systemd Timer

OnCalendar*-01,07-01 00:00:00

my-task.timer
[Unit]
Description=Timer for cron expression: 0 0 1 1,7 *

[Timer]
OnCalendar=*-01,07-01 00:00:00
Persistent=true

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How can I test a job that only runs twice a year?

Do not wait six months to test. Use a manual trigger mechanism or temporary schedule (like running every minute in a staging environment) to validate the business logic, and verify the cron definition separately using syntax parsers or dry-run tools.

What happens to this cron job during Daylight Saving Time transitions?

Since the job runs at midnight on January 1st and July 1st, DST transitions (which typically occur in March/April and October/November) will not directly affect the execution hours. However, always run your cron daemon on UTC to guarantee consistent execution.

Why is running this job on January 1st at midnight risky?

Midnight on January 1st is one of the most high-traffic, resource-intensive periods for global servers and databases due to year-end processing. Running massive bi-annual jobs at this exact second can lead to database locking and resource contention.

Can I schedule this to run on the last day of June and December instead?

Standard cron does not easily support 'last day of month' logic across different months without complex scripting. Running on the 1st of January and July (`0 0 1 1,7 *`) is the standard, cleaner alternative for bi-annual cadences.

How do I monitor a cron job that runs so infrequently?

Traditional pull-based monitoring is ineffective here. Use push-based heartbeats (like Dead Man's Snitch or Honeybadger) that alert you if they do not receive a ping on January 1st and July 1st within a small buffer window after midnight.

* Explore

Related expressions you might need

Last verified:

Was this helpful?