Can someone help me with setting the cron expression to run every 2 months starting from a particular day

Here is the one which I tried : public static String sch = '0 18 * */2 *';


1 Answer 1


The seven positions are: second, minute, hour, day, month, day of week, and year. So you need to choose a time (second, minute, and hour), specify the day, and then an increment month:

0 0 0 18 1/2 ?

The first three zeroes specify "midnight" on the chosen days. "1/2" specifies odd months (January, March, May...). You can change it to "2/2" if you want to specify even months (February, April, June...). Year, the seventh position, is optional, so I've omitted it here.

  • Never knew that there were CRON definitions with seven entries until today (threw me for a loop scheduling one of my jobs). Is this because of CronTrigger in Java? Commented Apr 13, 2023 at 20:36
  • 1
    @NobleUplift CRON originally comes from UNIX circa 1975. Java's CronTrigger came from from the original CRON. Apex was heavily influenced by Java, and so it is likely that the syntax was adopted so that experienced developers would already be familiar with the syntax.
    – sfdcfox
    Commented Apr 13, 2023 at 21:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .