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
*

Next 5 Runs

  • in 111d 13h
  • in 292d 13h
  • in 476d 13h
  • in 658d 13h
  • in 842d 13h

* Tools

Code & Implementations

nodejs
// Node.js production bi-annual task runner using node-cron
const cron = require('node-cron');
const winston = require('winston');

const logger = winston.createLogger({
  level: 'info',
  transports: [new winston.transports.Console()]
});

// Schedule for 0 0 1 1,7 * (Standard cron format)
cron.schedule('0 0 1 1,7 *', async () => {
  logger.info('Starting scheduled bi-annual database cleanup and audit...');
  try {
    // Simulate long-running maintenance task
    await performBiannualMaintenance();
    logger.info('Bi-annual maintenance completed successfully.');
  } catch (error) {
    logger.error('Failed to execute bi-annual task:', error);
    // In production, integrate with PagerDuty or Sentry here
  }
}, {
  scheduled: true,
  timezone: "UTC"
});

async function performBiannualMaintenance() {
  return new Promise((resolve) => setTimeout(resolve, 5000));
}
Setup notes

Install node-cron and winston via npm. This script schedules the job using the standard five-field cron format, running in UTC timezone to avoid daylight saving issues.

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

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

Was this helpful?

Last verified: