I have an Ubuntu Linux server that is running in a Vagrant virtual environment. I use the server for development of a web service. When the server starts up I have a shell script that needs to run once in order to setup a cache directory structure on the /tmp/
filesystem.
description "setup web cache"
start on startup
script
mkdir -p /tmp/cache/persistent
mkdir -p /tmp/cache/models
mkdir -p /tmp/cache/views
chmod -R 777 /tmp/cache/
end script
When I boot the server I get an error message that show up in /var/log/upstart/webcache.log
:
mkdir: cannot create directory `/tmp/cache': Read-only file system
Apparently startup
is too soon to start on
. The question is, when is /tmp
available for writing and what do I pass to start on
?
Since your job needs to start when local file system is mounted most likely you need following definition: start on local-filesystems
See local-filesystem event example.
You will find overview of well known Upstart events here.
Further on, your job is a short lived job and not a service/daemon. It will be more appropriate to use task stanza. In such way you might run a job that depends on cache directories created once those directories are actually created. Otherwise, if you define all dependent jobs to start runlevel [2345] dependent job might start before needed directories are created e.g. dependent job might use following definition: start on started webcache
.
description "setup web cache"
start on local-filesystems
task
script
mkdir -p /tmp/cache/persistent
mkdir -p /tmp/cache/models
mkdir -p /tmp/cache/views
chmod -R 777 /tmp/cache/
end script
Finally, you might consider using Vagrant shell provisioner to create needed cache directories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With