I need to write a program or a bash script, which will run every now and then (based on cron). The program will contain a state machine and will behave differently depending on which state it is in.

The program (or bash script) is not user specific, so it shouldn't be in the /home folder.

Where (by convention) to store the file with program internal state on Ubuntu Server?

Bonus question: What is the best place for the script itself?