I have installed the motion package on my pi (stretch). If I start motion in the foreground it's working but when I try to start it as a daemon it fails with the following log message:

motion: permission denied for /var/log/motion/motion.log

I've seen many approaches to fix this problem by tinkering with the permissions of /var/log/... but this does not convince me.

Q What's the correct way to fix this problem?


I've motion installed as a service and I start it for testing with

sudo service motion start

but even then it fails with the error message below

raspberrypi motion[323]: [0:motion] [ERR] [ALL] myfopen: Error opening file /var/log/motion/motion.log with mode a: Permission denied

5 Answers 5


Gotcha! For testing I started motion with sudo motion -b. Therefore, /var/log/motion/motion.log was written with root:root. After removing /var/log/motion and reboot, the motion-daemon was up and running and had the permission to write to the log.

  • Same thing happened to me. I think this should be the accepted answer. After removing the /var/log/motion directory, restart the service using sudo service motion restart and it works correctly.
    – jontsai
    Commented Oct 20, 2018 at 3:05
  • Same thing happened to me. Had to sudo rm -fr /var/log/motion then restart the service and now the right owner/group shows on that folder.
    – Josh P
    Commented Jan 4, 2020 at 15:22
  • 1
    This isn't working for me. The directory doesn't get created after a reboot and I get the same error with after sudo service motion restart
    – NickG
    Commented Apr 8, 2022 at 8:40
  • @NickG You need to remove /var/log/motion (i.e. sudo rm -r /var/log/motion) at first and then reboot. Commented Apr 19, 2022 at 15:40

There are three ways to fix the problem. All are really the same, just from different angles. That is to make sure that the user starting motion has the access permission to write into the /var/log/motion/ directory. First could just make that user the owner of the directory. And give the owner write access. The second would be start the daemon using root by using the sudo command. An alternative third method is to allow write access to the log directory for a group 'motion' and to make that a supplementary group of any user needing to be able to start the daemon.

E.g. Assuming you want to create group motion and add user pi

pi@raspberrypi:~$sudo groupadd motion pi@raspberrypi:~$sudo usermod -aG motion pi

Finally change the ownership and permission of the /var/log/motion directory

pi@raspberrypi:~$cd /var/log pi@raspberrypi:/var/log $ chown root:motion motion pi@raspberrypi:/var/log $ chmod 664 motion

It is simpler and more normal to start the daemon as the root user who should already have all the correct permissions by using sudo command as I already mentioned.

  • 1
    How do I know which user is running motion? (newby here)
    – NickG
    Commented Apr 8, 2022 at 8:40

I have tested all answers but no solution. After I reboot the raspberry pi, problem still there. Follow the procedure below to fix the problem.

Create another directory:

sudo mkdir /home/log/motion

Create a log file in this directory:

sudo touch /home/log/motion/motion.log

Change the config file as this new log file:

 nano /etc/motion/motion.conf

Add/change this line:

logfile /home/log/motion/motion.log

The important part is adding motion user permission to our new log file because it will run as motion:motion:

sudo chown motion:motion /home/log/motion/motion.log
  • 3
    Thank you! I've read so many answers and this is the first one that addresses the fact that motion runs as the motion user.
    – jsaven
    Commented Dec 31, 2020 at 5:33
  • /home/log- wouldn't that mean that the username is log? Commented Feb 26, 2022 at 16:40
  • @ThomasWeller My user was log on this example. Commented Feb 26, 2022 at 21:25

I made mistake and opened 2 sessions of Motion: 1. Was autostarted with Raspbian 2. Was initiated by me sudo motion

This initiated by me blocked file, sudo rm -rf /var/log/motion/* helped me.

  • How is this different from the accepted answer?
    – RalfFriedl
    Commented May 18, 2019 at 19:56
  • If you can't see ill explain you. If somebody will asking google with "sudo motion" he will find this answer. I explained one of cases.
    – Kamil
    Commented May 18, 2019 at 20:07

As of Raspian Stretch (4.19.27-v7+ #1206) and motion 3.2.12, this also worked:

  1. created a new directory (sudo mkdir /tmp/motion)
  2. change permissions (sudo chown motion:motion /tmp/motion)
  3. change logfile in /etc/motion/motion.conf to point to /tmp/motion (sudo nano /etc/motion/motion.conf and add logfile /tmp/motion)
  4. restart motion (sudo service motion restart).
  • The OP told you (albeit in a veiled way) that he/she is using Raspbian Stretch. So how is an answer about Motion on Ubuntu in any way relevant to that?
    – Dougie
    Commented Mar 31, 2019 at 8:41
  • Dougie ...Thanks ...a tired mind slips easily. Commented Apr 2, 2019 at 14:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.