How to listen for an incoming serial string inside loop with long delay? I'm trying to build a datalogger using Arduino UNO, I'll use RS232 for the communication between PC and Arduino, the problem I'm facing now is that I'm using delay(10000) : 10 seconds as a timestep for data acquisition. however, I can't find any solution to receive a string from the serial input to Arduino while delay is executing. Here is the code : 

void setup() {
  Serial.begin(9600);
}

void loop() {
  serialRoutine();
  dataLoggingEvery10Second(); // That's a function to receive data from the sensor and store it in SD card.
  delay(10000);
}

  // A function to handle all the serial in out
  void serialRoutine(){
  // print the string when a newline arrives:
  while(Serial.readString() == ""){
    String serstr = Serial.readString();
      /*
      *  Getters
      */
      if(serstr == "GETDATA"){
        Serial.println("Here is my data");
      } 
      serstr = "";
  }
}


Any help would be highly appreciated !
void loop() {
  static unsigned long prev = 0;
  unsigned long now = millis();

  if (now - prev &gt;= 10000L) {
    serialRoutine();
    dataLoggingEvery10Second();
    prev = now;
  }
}


This will executed at time 10s, 20s, etc. I