Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 3 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
add comment

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
    
I take that back, Motion handles SIGTERMs nicely :) –  Joril Jul 30 '10 at 14:24
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
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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