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

link|improve this question

73% accept rate
feedback

2 Answers

Use cron:

crontab -e

then put in it:

DISPLAY=:0.0
0 0 * * * /usr/bin/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.

link|improve this answer
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
I didn't get it: it works? – dag729 Jul 30 '10 at 15:12
show 3 more comments
feedback
up vote 2 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 
link|improve this answer
This is what I was looking for. Thank you. – Andrew May 4 at 22:22
feedback

Your Answer

 
or
required, but never shown

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