Reputation:
I'm writing a script which is to be executed hourly. It basically works as:
I will put the script in /etc/cron.hourly/ on Ubuntu which will make it execute once each hour.
What would a good place to store the datafile? The script is run as root.
Upvotes: 1
Views: 407
Reputation: 46965
If it's transient data then /tmp or /var/tmp are the standard directories. Persistent data can be placed in any area within the file system that the process can read from and write to. I typically create a "data" directory somewhere in the tree where the process has write permissions such as ~/data, /app/data etc.
Upvotes: 0
Reputation: 202645
First, both the datafile and the cron job should be named after your application. Second, if I understand correctly, your data is being changed by the cron job and is not edited by a human. The Filesystem Hierarchy Standard therefore says that if the application is named foo
then the cron job should be /etc/cron.hourly/foo
and the datafile should be /var/lib/foo
. The reason is that the purpose of /var/lib
is given as follows:
This hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host. Users must never need to modify files in
/var/lib
to configure a package's operation.
Upvotes: 4
Reputation: 64929
A subdirectory of /var
is the right place for data that will be read and modified by the system. See the Filesystem Hierarchy Standard for more information.
Upvotes: 1
Reputation: 34195
If it's read-only data:
/usr/local/share/program_name
If it's a config file (or files):
/usr/local/etc/program_name
Unless it's something very specific that should go into /var/spool, /var/run or somewhere else. There's also the /opt/XXX
school...
Upvotes: 0
Reputation: 13893
/opt
and/or /var
are typically good places for this. Obviously narrow it down from there.
Upvotes: 2