#!/bin/bash # define interval(seconds) after which you want the script to wake up interval=180 sleep 1000 # start infinite loop while [ 1 ] do # first sleep interval seconds sleep ${interval} # next check condition on which you want VASP to stop ./check_hcl grep "E0= " OSZICAR | tail -n 1 | awk '{print $9}' >> trajectory.dat done