Search code examples
nginxubuntu-14.04file-permissionsupstart

Ubuntu upstart won't start program due to log file creation failure


I have an upstart script as follows.

#!upstart
description "example site services"
author "Peter"

start on startup
stop on shutdown

respawn

script
echo $$ > /var/run/website.pid
exec /etc/nginx/website 2>&1
end script

pre-start script
echo "[Fri Sep 11 02:04:39 UTC 2015] (sys) Starting" >> /var/log/website.sys.log
end script

pre-stop script
rm /var/run/website.pid
echo "[2015-09-11T02:04:39.444Z] (sys) Stopping" >> /var/log/website.sys.log
end script

This should automatically start the Nginx website.

However, in the startup log I get this message.

/bin/sh: 1: /bin/sh: cannot create /var/log/website.sys.log: Read-only file system

I have tried changing the permissions on this file. Its currently root root with both rw permissions. It is still not working.

-rw-rw-r--  1 root      root       1506 Sep 27 21:39 website.sys.log

What am i doing wrong?


Solution

  • I hate answering my own question but found a solution which worked for me.

    It was to not specify the log location.

    I have changed

    echo "[Fri Sep 11 02:04:39 UTC 2015] (sys) Starting" >> /var/log/website.sys.log
    

    to

    echo "[Fri Sep 11 02:04:39 UTC 2015] (sys) Starting"