On Ubuntu:
touch: cannot touch `/var/run/test.pid': Permission denied
I am starting start-stop-daemon and like to write the PID file in /var/run
start-stop-daemon is run as my-program-user
/var/run setting is drwxr-xr-x 9 root root
I like to avoid putting my-program-user in the root group.
Best Answer
By default, you can only write to /var/run as a user with an effective user ID of 0 (ie as root). This is for good reasons, so whatever you do, don't go and change the permissions of /var/run... Instead, as root, create a directory under /var/run:
# mkdir /var/run/mydaemon
Then change its ownership to the user/group under which you wish to run your process:
# chown myuser:myuser /var/run/mydaemon
Now specify to use /var/run/mydaemon rather than /var/run.
You can always test this by running a test as the user in question.