I have a cron that I am writing that will repeat every hour, and I need a simple way to pass a counter from the last run to the next run.
My plan was to add the number to a file at the end, and then call it back at the beginning, e.g.
At end of the first cron run:
INC_COUNT=1 echo $INC_COUNT > inc_counter.txt
Then at the start of the second run:
INC_COUNT_FILE="inc_counter.txt" OLD_INC_COUNTER=$(cat "$INC_COUNT_FILE")
So far so good, but now I need to increment that number. I tried:
neither of which worked. What is the best way to increment this number?