Search code examples
cronexpression

how to write a cron expression which run at 12 pm and run for every two hours till 12 am and runs everyday for same?


JobDetail Management = new JobDetail("Management", "NJobGroup", ClinicSubscription.class);

CronTrigger cr = new CronTrigger("ccr", "NJobGroup", "0 0 00 * * ?"); sche.scheduleJob(clinicManagement, cr);


Solution

  • Midnight (0) or every two hours (/2) in the range midday to ten pm, inclusively (12-22):

    0 0,12-22/2 * * * command.sh