2

I have some problems with starting Motion software with my Raspberry Pi4 Model B 4 RAM. I have installed motion with comand line : sudo apt-get install motion The motion version is 4.1.1

After I have tried to run motion as a serivce and for this I have modified the daemon configuration in /etc/default/motion where I putted daemon = yes and in /etc/motion/motin.conf where i putted daemon = on.

After I rebooted my Raspberry Pi and if I try to digit: sudo service motion status I always get this message I attached , that said "... permission denied " and then motion never start as a service.

This is the message :

● motion.service - LSB: Start Motion detection
   Loaded: loaded (/etc/init.d/motion; generated)
   Active: active (exited) since Thu 2021-11-04 16:01:10 CET; 19min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 409 ExecStart=/etc/init.d/motion start (code=exited, status=0/SUCCESS)

nov 04 16:01:09 raspberrypi systemd[1]: Starting LSB: Start Motion detection...
nov 04 16:01:10 raspberrypi motion[409]: Starting motion detection daemon: motion.
nov 04 16:01:10 raspberrypi systemd[1]: Started LSB: Start Motion detection.
nov 04 16:01:11 raspberrypi motion[494]: [20792968:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
nov 04 16:01:11 raspberrypi motion[494]: [20792968:motion] [NTC] [ALL] motion_startup: Motion 4.1.1 Started
nov 04 16:01:11 raspberrypi motion[494]: [20792968:motion] [ERR] [ALL] myfopen: Error opening file /var/log/motion/motion.log with mode a: Permission denied
nov 04 16:01:11 raspberrypi motion[494]: [20792968:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/motion/motion.log: Permission denied

~

I don't understand why I'm getting this message of permission denied. I ask you please if someone could help me, thank you !

After i use the ls -l comand i get this :

pi@raspberrypi:~ $ ls -la /var/log/motion

drwxr-xr-x 2 root root 4096 nov 4 15:28 .

drwxr-xr-x 9 root root 4096 nov 6 15:30 ..

-rw-r--r-- 1 root root 50228 nov 5 17:51 motion.log

pi@raspberrypi:~ $ ls -l /var/log/motion

-rw-r--r-- 1 root root 50228 nov 5 17:51 motion.log

And then

pi@raspberrypi:/var/log/motion $ ls -l motion.log

-rw-r--r-- 1 root root 50228 nov 5 17:51 motion.log

5
  • Have you checked the directory /var/log/motion/ mentioned in the log? Does it exist and what are the permissions for the motion user? Is there a motion.log file in it and is it writable for the motion user?
    – Robert
    Nov 4, 2021 at 21:11
  • Hi, i'm sorry but i don't know how I could see the permissions for the motion user. I always write the comand line as pi user ( or sometimes as a root user but it show the same error ) using sudo. Could you explain how could I see the permission of the motion user please ? Thank you very much for your suggestion.
    – DanielePP
    Nov 4, 2021 at 22:02
  • I assume you know ls -l? Based on the shown permissions for user/group/other and shown file/dir owner and group you can calculate which permissions apply for the motion user.
    – Robert
    Nov 5, 2021 at 8:16
  • I saw in the directory /var/log/motion that the motion.log file exists. I don't know how to see if is writeble for the motion user and I don't how to calculate the permissions for the motion user. Thank you again for your help !
    – DanielePP
    Nov 5, 2021 at 16:48
  • Please to not try to post listings in comments. Edit your question and paste the information there.
    – Robert
    Nov 5, 2021 at 16:50

3 Answers 3

0

I would suggest building from source and installing in /usr/local/etc/motion folder. That's how I run it and I don't run into any permission issues. The person who manages the project suggests doing it this way, and I believe the repo that you get from apt is outdated. See the docs here for steps on how to do that: https://motion-project.github.io/motion_build.html

0
0

I think I have succesfull solved my question.

I would have change the user from root:root to motion : motion user using

sudo chown motion:motion motion.log

Now It works, and motion is starting as a service.

Thank you everybody for your help! Bye

0

Out of the box, on my Raspberry Pi Ubuntu Server 20 LTS, I also encountered this problem:

motion[3733241]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/motion/motion.log: Permission denied

It seems that at least with Ubuntu 20 LTS, after installation with sudo apt install motion, the directory /var/log/motion is owned by root:root, therefore the standard motion user motion cannot create, append, or delete files within it.

I fixed the issue by recursively changing the ownership of directory /var/log/motion and all its possibly already contained files and subdirectories to motion:adm (group adm being a conventional Debian administrator group):

chown -R motion:adm /var/log/motion

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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