On a normal startup after booting the login prompt appears from where I would login. But after making motion autostart I am unable to login or open GUI because motion is using the command line to display status of recording.

I am using motion to record video streams on Linux. In the folder


a script was written to execute motion at startup.

case $1 

        echo "Starting Motion..."
        sudo motion

        # when the init daemon performs a shutdown the motion is terminated 
        kill $(pidof motion)




exit 0

This script was made executable and added to boot sequence. My runlevel is 3 (commandline).


You need to start motion as a daemon, using start-stop-daemon or something similar. The simplest solution is to use the motion package in Debian and its init script, which starts motion as follows:

start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion

(DAEMON is /usr/bin/motion). To have the daemon start automatically you need to edit /etc/default/motion.

  • Currently I just can't do anything because the command line is occupied. – Osaid Jul 14 '15 at 12:55
  • Can't you stop motion with Ctrl+C? – Stephen Kitt Jul 14 '15 at 12:56
  • No. The command line seems not to be taking any commands to process. It just echos different status like new video file being created etc. – Osaid Jul 14 '15 at 12:58
  • 1
    Then you'll need to reboot in rescue mode (there's an option in the Grub menu). – Stephen Kitt Jul 14 '15 at 13:00
  • 1
    OK, so power off your Pi, mount the SD card in another computer, remove the faulty init script, replace the SD card in the Pi and boot it. – Stephen Kitt Jul 14 '15 at 13:35

The problem most likely is because your initscript start action doesn't exit. Initscripts in general should start daemon processes and exit after the process has been started (or do one-off jobs, like mounting a filesystem for example).

You should propably use start-stop-daemon to "daemonize" motion.

The Debian initscript template should be in /etc/init.d/skeleton on your system, you could copy it to /etc/init.d/motion and try to edit it to your needs.

Also there's an initscript available in Mr-Dave fork of motion but this will probably also need some tuning (a motion user is used there for example) Given all that, motion is already packaged in Debian: and it has a nice initscript. Why won't you use that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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