Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :)

share|improve this question
up vote 4 down vote accepted

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 
share|improve this answer
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 Nov 26 '12 at 16:12

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.

share|improve this answer
1  
You'll also need to add an entry to stop motion during the day. 0 8 * * * killall motion – Chris Nava Jul 30 '10 at 3:45
    
@Chris Nava: Oops...you're right! But instead of "killall" the full path must be used. Usually /usr/bin/killall – dag729 Jul 30 '10 at 11:06
    
Well that's quite "brutal" but I'll try it out, thanks :) – Joril Jul 30 '10 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 Jul 30 '10 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 Jul 30 '10 at 19:43

You must log in to answer this question.

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