I'm trying to set up the raspberry pi with my webcam as a motion detecting cctv that uploads the videos to google drive using Jeremy Blythe's script

I have motion working correctly and the python script runs when I test it from the terminal.

However the script doesn't run when I add it to the on_movie_end option in motion.conf.

The script I am using in the file is

On_Movie_End /etc/motion/uploader.py /etc/motion/uploader.cfg %f

I have also tried getting the on_movie_end to run a bash script that runs the python script and this doesn't work either. I am new to linux though so not entirely sure I have it correct.

The script is:

/etc/motion/uploader.py /etc/motion/uploader.cfg VIDEO

In motion.conf /etc/motion/uploaderscript.sh %f

  • Perhaps you should do /usr/bin/python /etc/motion/uploader.py /etc/motion/uploader.cfg VIDEO. Or check if python binary is installed in other directory and change the above line.
    – Luis
    Commented Dec 21, 2012 at 11:20
  • 1
    in bash you should have to use variable as /etc/motion/uploader.py /etc/motion/uploader.cfg $VIDEO Commented Dec 21, 2012 at 11:22
  • neither of those solutions work but I suspect the on_movie_end is not being called as I tried to get it to just open leafpad to see if that was working and it didn't
    – DanBrum
    Commented Dec 21, 2012 at 12:39

4 Answers 4


Check the following points:

  1. All the examples I saw use on_movie_end instead of On_Movie_End. So try using the lowercase version first.

  2. Check if both script have execution permission. If not add it:

    sudo chmod +x /etc/motion/uploader.py
    sudo chmod +x /etc/motion/uploaderscript.sh
  3. Redirect the stderr of the python script to a file. That can help to catch a error. Edit the .sh file to match this (note the $VIDEO: it is the correct way to reference a variable in bash):

    /etc/motion/uploader.py /etc/motion/uploader.cfg $VIDEO &> /tmp/on_movie_end.log

I still haven't been able to figure out how to play a python script from motion. Instead, I just run a bash script which creates a text file. On start-up, I have the actual python script running a while loop, checking to see if the text file exists, and will run the rest of the script once it does.


This configuration works for me:

on_movie_end /usr/bin/python /home/myuser/Scripts/MyScript.py

Of course, the script must have the correct permissions to be executed by the motion process. More details on the configuration can be found in the Motion Docs:



I have a simple solution but someone needs to explain how this works. Start motion as root. Add a line to /etc/rc.local 'sudo motion' reboot and most events will work if started as root, on_event_end sudo ...command or script...

  • 2
    It is not recommended to run a whole daemon as root if it would simply be enough to set the correct permissions for your script. Commented Mar 8, 2022 at 3:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .