4

I've just discovered Motion and it works like a charm.. My only problem is that I'd like it to be active only during night-time, but there's no parameter for scheduling..

I think I could write a program that would control Motion via its "HTTP API", but I was wondering if someone had already done that, or if there's an alternative solution.

Thanks in advance :)

2 Answers 2

6

For this simple task, Motion's HTTP API can be used directly with wget or similar..
Straight from the FAQ:

0 9 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/start > /dev/null 
0 18 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/pause > /dev/null 
1
  • 1
    Note that this pauses the motion capture, but does not turn off the camera or the live feed. Killing motion turns off the camera.
    – endolith
    Commented Nov 26, 2012 at 16:12
2

Use cron:

crontab -e

then put in it:

DISPLAY=:0.0
0 0 * * * /usr/bin/motion 
0 8 * * * /usr/bin/killall motion

I'm assuming that you want to open "motion" at midnight everyday, and that motion path is /usr/bin/motion: custom this crontab to your needs and it'll do the trick.

8
  • 1
    You'll also need to add an entry to stop motion during the day. 0 8 * * * killall motion
    – Chris Nava
    Commented Jul 30, 2010 at 3:45
  • @Chris Nava: Oops...you're right! But instead of "killall" the full path must be used. Usually /usr/bin/killall
    – dag729
    Commented Jul 30, 2010 at 11:06
  • Well that's quite "brutal" but I'll try it out, thanks :)
    – Joril
    Commented Jul 30, 2010 at 12:01
  • 1
    @Joril: of course the method you posted as an answer is better suited for this situation. My answer is a generic way to do almost...everything! ("Ehy mama, can you please wake me up at 6 a.m.?" "Of course" "crontab -e : 0 6 * * * /usr/bin/wake_up_son")
    – dag729
    Commented Jul 30, 2010 at 17:56
  • 1
    If this were a production system I would avoid killall and instead log the process ID of motion and kill just that. If it's a home machine I doubt you'll run another process named motion unknowingly.
    – Chris Nava
    Commented Jul 30, 2010 at 19:43

You must log in to answer this question.

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