Runs an output one time

I am a beginner to Arduino and programming and I am trying to do a piece of code that runs once every thirty minutes for a short period of seconds.

I figured out how to do it every once an hour but I cannot figure out how I am going to stop it for the rest of the remaining minute.

This is the code:

if ((incubationMinutes % 30 == 0 && motorIdentifier == 1) && (incubationTime/86400 >= incubationDays - 3))
{
if(timeConveyorWatch != timeInMillis)
{
conveyorStateRunningTime++;
timeConveyorWatch = timeInMillis;
}

if (conveyorRunningTime >= conveyorStateRunningTime)
{
motorIdentifier = 1;
digitalWrite(conveyor, HIGH);
}

else if (conveyorRunningTime <= conveyorStateRunningTime)
{
motorIdentifier = 0;
digitalWrite(conveyor, LOW);
timeConveyorWatch = 0;
}
}

The conveyorStateRunningTime is increasing by one every milli second.
Now how I am going to activate the motorIdentifier once every 30 minutes and making it 0 again as the conveyorRunningTime has expired.
Thanks

I figured out how to do it every once an hour but I cannot figure out how I am going to stop it for the rest of the remaining minute.

Bring seconds into the equation.
At every 30 minutes and seconds is between say 0 and 5 (or whatever) then you do your stuff.

.

I think it would be easier to understand your logic if you break that complex IF statement into a few nested IF statements

if (motorID == 1) {
   if (daysSoFar < limitDays) {
      if (thirtyMinutesAreUp) {
          motorOn = true;
          motorStartMillis = millis();
          // other stuff
      }
  }
}
if (motorOn == true) {
   if (millis() - motorStartMillis > = motorRunMillis) {
       motorOn = false;
       // code to stop motor
   } 
}

...R