Where to store program internal state?
Solution 1:
What is the best place for the script itself?
That could be ...
/usr/local/bin/
Where (by convention) to store the file with program internal state on Ubuntu Server?
I do not think there is such a location. You could use /var/local/
. I have seen several methods and a popular one seems to use /opt/
. In this fashion:
/opt/{software_name}/
/opt/{software_name}{.version_1}/
/opt/{software_name}{.version_2}/
...
where the 1st is a symlink to the active version. And a ./bin
inside those directories for the binaries, a ./log
for a (rotated) log, and in your case a ./state
with or without a unique identifier. And all set to user root with permissions n00
so nobody can read the content of "state".
Makes it clear where you can find anything you need.
Solution 2:
I'd make a folder for the data in /var/local/
and store the script in /usr/local/bin/