You can keep the last run date in a file:
date +"%s" > last_file
last_file
is the filename here. This writes seconds since the epoch started, eg. 1549605438. Once you have this, you can read it with:
read last < last_file
Here last
is a shell variable name. Once you have this, you need some arithmetic to make the comparison:
threshold=900 # 60 * 15 = 15 minutes
[ "$(date +'%s')" -gt "$((last + threshold))" ] || exit
Compare the second count now to the last one plus the set pause interval. Exit if not enough time has left yet. Continue otherwise -- the rest of the script is executed.
Finally, you need some semaphore to prevent two instances starting about the same, ie. process 2 starts before process 1 has already checked the last run date and written its own.
The full algorithm looks so:
- Set semaphore.
- Read the last run time.
- If you have a green light, write your own run time (possibly later, once you've finished the operations proper).
- Do the things this script is about.
- Release the semaphore.
You need to remember that before the first run of the script the last_file
will not exist unless you place it there manually. So either place it there or make your script immune to this by appropriate logic.