Control several relays at the same time

Good afternoon,
I'm building a project with a lot of eight relay. But I came up with the following problem: one of the relays is to control a fan, in which when I execute a command it will work for X seconds, but while it works I like to control the rest of the relays. The problem is that if I use the delay, the arduino blocks and does not let me do anything else in those x seconds. I tried to use the "millis ()" function but it just tells me the current time. And the fan does not turn itself off automatically! BELOW THE CODE:

//name of ports
int valv1=2;
int valv2=3;
int valv3=4; 
int valv4=5;
int valv5=6;
int valv6=7;
int valv7=8;
int fan=9;

unsigned long previousTime=5000;
unsigned long interval=0;


void setup() {
  pinMode(valv1, OUTPUT);
  pinMode(valv2, OUTPUT);
  pinMode(valv3, OUTPUT);
  pinMode(valv4, OUTPUT);
  pinMode(valv5, OUTPUT);
  pinMode(valv6, OUTPUT);
  pinMode(valv7, OUTPUT);
  pinMode(fan, OUTPUT);
 
  Serial.begin(9600);

  //Close Relays
  digitalWrite(valv1, HIGH);
  digitalWrite(valv2, HIGH);
  digitalWrite(valv3, HIGH);
  digitalWrite(valv4, HIGH);
  digitalWrite(valv5, HIGH);
  digitalWrite(valv6, HIGH);
  digitalWrite(valv7, HIGH);
  digitalWrite(fan, HIGH);
}

void loop() {
  int valor2 = digitalRead(valv2);
  int valor3 = digitalRead(valv3);
  int valor4 = digitalRead(valv4);
  int valor5 = digitalRead(valv5);
  int valor6 = digitalRead(valv6);
  int valor7 = digitalRead(valv7);
  int valuefan = digitalRead(fan);

  String opc; 
  opc=Serial.readString();

  if(opc == "ov1"){ 
    digitalWrite(valv1, LOW); 
    Serial.println("Valvula 1 Aberta"); 
  }
    
  if (opc == "ov2")
  {
    digitalWrite(valv2, LOW);
    Serial.println("Valvula 2 aberta");
  }
  
  if (opc == "ov3")
  {
   digitalWrite(valv3, LOW);
   Serial.println("Valvula 3 aberta");
  }
    
  if (opc == "ov4")
  {
   digitalWrite(valv4, LOW);
   Serial.println("Valvula 4 aberta");
  }
  
  if (opc =="ov5")
  {
    digitalWrite(valv5, LOW);
    Serial.println("Valvula 5 aberta");
  }
  
  if (opc =="ov6")
  {
    digitalWrite(valv6, LOW);
    Serial.println("Valvula 6 aberta");
  }
  
   if (opc =="ov7")
  {
    digitalWrite(valv7, LOW);
    Serial.println("Valvula 7 aberta");
  }
  //open fan
  if (opc =="fan")
  { 
    unsigned long currentTime= millis(); 

    if(currentTime - previousTime > interval) { 
      previousTime = currentTime;    

      if (valuefan == HIGH) {
   valuefan = LOW;
        Serial.println("fan open");
      }
      else {
        valuefan = HIGH;
      }
      digitalWrite(fan, valuefan);
      
    } 
  }
}

Thanks!!!

The problem is that if I use the delay, the arduino blocks and does not let me do anything else in those x seconds.

No, no. It is not the Arduino that is blocking. It is the sketch that you have given it. You just need a better sketch. This is a very common question: how do I get the Arduino to do more than one thing at once. The answer is: you don't. The Arduino has only one CPU. It can only do one thing at once. But it is so fast, it can appear to to many things at once, to the human eye.

You are correct to say that millis() just gives you the current time. But that is the secret to get the Arduino to do what you want it to do!