diff --git a/.gitignore b/.gitignore
index 67c91ae606a74e51426d7703a97087ee0179738e..6d0e360748e321a62e42d4ecefb46ce5928d67de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,5 +3,4 @@ out/*
 CHANGELOG.md
 data/data
 logs/log
-profiling.log
-profiling_trace.json
\ No newline at end of file
+profiling.log
\ No newline at end of file
diff --git a/main.py b/main.py
index 76b4d1d7021b482cd1db9554d06ad37592ec8a02..b89bfdf53daba8bcc877fe4d80a662ed25ab2948 100644
--- a/main.py
+++ b/main.py
@@ -3,6 +3,7 @@ import yaml
 import time
 from typing import Any, List, Optional
 import serial
+import serial.serialutil
 from pathlib import Path
 import logging
 import logging.handlers
@@ -62,7 +63,7 @@ def convert(data) -> str:
 
 
 def get_offset() -> np.ndarray:
-    files = sorted(glob.glob(str(Path.joinpath(Path(__file__).parent, "data", "log.*.log"))))
+    files = sorted(glob.glob(str(Path.joinpath(Path(__file__).parent, "data", "data.*.log"))))
 
     if files:
         for file in files[::-1]:
@@ -94,7 +95,7 @@ def setup_loggers(config: Any) -> None:
         TimedRotatingFileHandlerWithHeader(
             header=f"Timestamp,{','.join([f'dms{i+1}' for i in range(4)])},{','.join([f'temp{i+1}' for i in range(4)])},n",
             filename=f"{Path(__file__).parent}/data/{config['DataLogger']['filename']}",
-            when='h',
+            when="h",
             interval=25,
             backupCount=config["DataLogger"]["backupCount"],
         )
@@ -142,51 +143,54 @@ def main(config: Any) -> None:
         f"Factors: {', '.join(f'{factor:.3f}' for factor in factors[:4])}, Offset: {', '.join(f'{offset:.3f}' for offset in offsets[:4])}"
     )
 
-    with serial.Serial("/dev/ttyACM0", 9600, timeout=3) as con1, serial.Serial("/dev/ttyACM1", 9600, timeout=3) as con2:
-        logger.warning("Connected to serial ports")
-        last_write = time.time()
-        data = np.zeros((8,))
-        n = 0
-        recv1, recv2 = None, None
-        off1, off2 = None, None
-        while datetime.datetime.now() - datetime.timedelta(seconds=delta_time) < end_time:
-
-            try:
-                new_data = data.copy()
-
-                # offsets for writing data of each arduino in correct column
-
-                
-                con1.write(1)
-                off1 = 0 if int(convert(con1.readline())) == 1.0 else 4
-
-                # read data
-                for i in range(4):
-                    recv1 = con1.readline()
-                    new_data[i + off1] += float(convert(recv1))
-                    recv1 = None
-                    
-                con2.write(2)
-                off2 = 4 if int(convert(con2.readline())) == 2.0 else 0
-
-                for i in range(4):
-                    recv2 = con2.readline()
-                    new_data[i + off2] += float(convert(recv2))
-                    recv2 = None
-
-                n += 1
-                data = new_data
-            except (TypeError, ValueError):
-                # may occur if no data was read over serial
-                logger.info(f"Didn't receive data from arduino, off1: {off1}, off2: {off2}, recv1: {recv1}, recv2: {recv2}")
-
-            if time.time() - last_write > delta_time:
-                # write data
-                data_logger.info(",".join([f"{(value/n) * factors[i]:.5f}" for i, value in enumerate(data)]) + f",{n}")
-                logger.debug("Wrote data")
-                n = 0
-                data = np.zeros((8,))
-                last_write = time.time()
+    try:
+        with serial.Serial("/dev/ttyACM0", 9600, timeout=3) as con1, serial.Serial("/dev/ttyACM1", 9600, timeout=3) as con2:
+            logger.warning("Connected to serial ports")
+            last_write = time.time()
+            data = np.zeros((8,))
+            n = 0
+            recv1, recv2 = None, None
+            off1, off2 = None, None
+            while datetime.datetime.now() - datetime.timedelta(seconds=4 * delta_time) < end_time:
+
+                try:
+                    new_data = data.copy()
+
+                    # offsets for writing data of each arduino in correct column
+
+                    con1.write(1)
+                    off1 = 0 if int(convert(con1.readline())) == 1.0 else 4
+
+                    # read data
+                    for i in range(4):
+                        recv1 = con1.readline()
+                        new_data[i + off1] += float(convert(recv1))
+                        recv1 = None
+
+                    con2.write(2)
+                    off2 = 4 if int(convert(con2.readline())) == 2.0 else 0
+
+                    for i in range(4):
+                        recv2 = con2.readline()
+                        new_data[i + off2] += float(convert(recv2))
+                        recv2 = None
+
+                    n += 1
+                    data = new_data
+                except (TypeError, ValueError):
+                    # may occur if no data was read over serial
+                    logger.info(f"Didn't receive data from arduino, off1: {off1}, off2: {off2}, recv1: {recv1}, recv2: {recv2}")
+
+                if time.time() - last_write > delta_time:
+                    # write data
+                    data_logger.info(",".join([f"{(value/n) * factors[i]:.5f}" for i, value in enumerate(data)]) + f",{n}")
+                    logger.debug("Wrote data")
+                    n = 0
+                    data = np.zeros((8,))
+                    last_write = time.time()
+    except serial.serialutil.SerialException:
+        logger.exception("SerialException was caught, shutting down.")
+        sys.exit(15)
 
     fh[0].doRollover()
 
diff --git a/measure.py b/measure.py
index c9b174a04813e69bc38209e0b4dd22537dbb2866..8604a215e0c7f25ace3d0ecc589cfc7476c77e73 100644
--- a/measure.py
+++ b/measure.py
@@ -136,7 +136,7 @@ def loop(con1: serial.Serial, con2: serial.Serial):
 
 def main() -> None:
     with serial.Serial("/dev/ttyACM0", 9600, timeout=3) as con1, serial.Serial("/dev/ttyACM1", 9600, timeout=3) as con2:
-        for _ in range(100):
+        for _ in range(50):
             loop(con1, con2)
 
 
diff --git a/scripts/push.bash b/scripts/push.bash
index f2fc0070743c271eaac76da8900536d743ae9195..98fd5889e53e920631bfb20662e55af45c9578c4 100755
--- a/scripts/push.bash
+++ b/scripts/push.bash
@@ -1,6 +1,28 @@
 #!/bin/bash
 
+ls -la .
+ls -la data
+ls -la log
+
+pip install multiprocessing_logging
+python3 measure.py
+
 git add .
 git commit -m "New data" && git push --force
-echo ""
-python3 main.py
\ No newline at end of file
+echo -e "Starting python script:\n"
+loop_count = 1
+while : ; do
+    python3 main.py
+    return_code=$?
+    if [[ "$return_code" -eq 0 ]]; then
+        echo -e "\nPython script ended"
+        break
+    fi
+    if [[ "$loop_count" -eq 10 ]]; then
+        echo -e "\nPython script failed too many times, trying again tomorrow"
+        break
+    fi
+    echo -e "Ended with error, waiting and trying again"
+    loop_count=$((loop_count + 1))
+    sleep $((loop_count * 60))
+done
\ No newline at end of file