LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-06-2017, 11:07 AM   #31
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by BW-userx View Post
How to set up "Motion" video surveillance on a Linux system - Part 1

How to set up "Motion" video surveillance on a Linux system - Part 2

they may help you --
off the top of my head without watching these vids. I'd do this with your script.

Code:
#!/bin/bash
echo "foo"
#pkill motion

Log_File="/where/ever/you/want/it/LogFile.log"

Images1=/home/scott/testmotion/motion-files

Move_Images_to="/home/scott/testmotion/motion-files"



Test_folder=/home/scott/testmotion/motion-files

#put a counter in it to split up your images dir a little more?

Runcount=1

while [[ true ]]
do
#inside loop to get updated with each pass.

Date="$(date +%F-%H:%M:%S)"

#only increment it in the first line so it matches in
# second line.

mkdir -pv "$Move_Images_to-$((Runcount++))-$Date" >> $Log_File

mv -v "$Images1" "$Move_Images_to-$Runcount-$Date" >> $Log_File


mkdir -pv "$Test_folder" >> $Log_File


#shut down motion how ever it gets shut down
#and remove PID

rm /path/to/PID

sleep 60 

or whatever time one wants.
then call to restart after sleep.
you dir are already set up for it. 

#restart motion

motion -c /path/to/config/file

done
something like that ..

motion(1) - Linux man page


I got a say whoever wrote this didn't think far enough past his nose to think someone would want to start, stop, and maybe even pause this application and code it to allow it to be done. making this process a lot easier.

note that is not a completely working script, just an Idea ...

this just shows how the log file looks, maybe redundant or over kill in what you are doing but might come in handy.
Code:
userx%slackwhere ⚡ ~ ⚡> mkdir -vp my/test/dir/ > testLog

userx%slackwhere ⚡ ~ ⚡> cat testLog
mkdir: created directory 'my'
mkdir: created directory 'my/test'
mkdir: created directory 'my/test/dir/'
userx%slackwhere ⚡ ~ ⚡> cd my
userx%slackwhere ⚡ my ⚡> ls
test
userx%slackwhere ⚡ my ⚡> cd test
userx%slackwhere ⚡ test ⚡> ls
dir
userx%slackwhere ⚡ test ⚡>
MOD: hours later I see its been marked solved, so .. goody -- now you can be a spy master.
Thanks for looking at this.
It does not seem to be a problem, my script with not stopping motion and renaming dirs while it is running.
You said this

#shut down motion however it gets shut down
#and remove PID

That is a good question, how to stop it, If anyone knows, could they tell me exactly how?
using 'pkill motion' terminates the script, so must be an error?
but it does kill motion running from a terminal.
 
Old 07-06-2017, 11:43 AM   #32
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
on_event_end string

gap integer
Values: 0 - 2147483647 / Default: 60
Gap is the seconds of no motion detection that triggers the end of an event.
An event is defined as a series of motion images taken within a short timeframe.


ffmpeg_timelapse boolean
Values: 0 - 2147483647 / Default: 0 (disabled)
Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used.
ffmpeg_timelapse_mode discrete strings
Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual / Default: daily
The file rollover mode of the timelapse video.



Code:
ffmpeg_timelapse=1 (true)
ffmpeg_timelapse_mode=hourly
that this one

on_event_end string
Values: Max 4095 characters / Default: Not defined
Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command.

if on_event_end do whatever it does,

I wish I had a camera to play with to figure it out so I could code and see what does what. but I think it does not turn off per se' but it looks like you can put it into a rest period using them config commands.

https://linux.die.net/man/1/motion


http://www.lavrsen.dk/foswiki/bin/vi...eBasicFeatures

Motion 3.1
Quote:
You use a combination of the Motion remote control and the Linux cron daemon which all
Linux systems have. Let us take the example that we want to enable motion detection at
9:00 in the morning and turn it off at 18:00. Motion 3.1 must be built with xmlrpc. If
you use 3.2 Motion is remote controlled using a browser.

Code:
0 9 * * * root /usr/local/bin/motion-control detection resume 
0 18 * * * root /usr/local/bin/motion-control detection pause
motion 3.2
Quote:
From motion 3.2 there is no longer a motion-control program.
Instead you use a program that can fetch a webpage. We simply
just throw away the html page that Motion returns.
Programs commonly available on Linux machines are wget and lwp-request.

Code:
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
in link below

http://www.lavrsen.dk/foswiki/bin/vi...AskedQuestions

Last edited by BW-userx; 07-06-2017 at 11:58 AM.
 
Old 07-06-2017, 12:44 PM   #33
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
on_event_end string

gap integer
Values: 0 - 2147483647 / Default: 60
Gap is the seconds of no motion detection that triggers the end of an event.
An event is defined as a series of motion images taken within a short timeframe.


ffmpeg_timelapse boolean
Values: 0 - 2147483647 / Default: 0 (disabled)
Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used.
ffmpeg_timelapse_mode discrete strings
Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual / Default: daily
The file rollover mode of the timelapse video.



Code:
ffmpeg_timelapse=1 (true)
ffmpeg_timelapse_mode=hourly
that this one

on_event_end string
Values: Max 4095 characters / Default: Not defined
Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command.

if on_event_end do whatever it does,

I wish I had a camera to play with to figure it out so I could code and see what does what. but I think it does not turn off per se' but it looks like you can put it into a rest period using them config commands.

https://linux.die.net/man/1/motion


http://www.lavrsen.dk/foswiki/bin/vi...eBasicFeatures

Motion 3.1

motion 3.2


in link below

http://www.lavrsen.dk/foswiki/bin/vi...AskedQuestions
Interesting idea, use crontab to pause motion, then use it to start motion.
I set my chron -e to run my script at midnight
So could the pause line pause motion at 23:59 ?
then cron runs my script, my script includes starting motion so would not need to use the resume

Alternatively, could my script execute the crontab command in itself, written into the script to pause motion??
Thing is I see 'root' in there, so I assume it can not.

Right now for testing, my script run every hour. Can that pause command be told to run one minute before every hour just for testing purposes?

So far the script has not caused a failure of motion, even though motion is not stopped, killed, or paused, so dont know how important to pause motion.

And at night, no advantage to pause motion as it is so dark, the camera can see any motion anyway. But if someone came by with a light, then motion is running and will record pics.
https://help.ubuntu.com/community/CronHowto

Last edited by sdowney717; 07-06-2017 at 12:52 PM.
 
Old 07-06-2017, 12:52 PM   #34
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by sdowney717 View Post
Interesting idea, use crontab to pause motion, then use it to start motion.
I set my chron -e to run my script at midnight
So could the pause line pause motion at 23:59 ?
then cron runs my script, my script includes starting motion so would not need to use the resume

Alternatively, could my script execute the crontab command in itself, written into the script to pause motion??
Thing is I see 'root' in there, so I assume it can not.

Right now for testing, my script run every hour. Can that pause command be told to run one minute before every hour just for testing purposes?

So far the script has not caused a failure of motion, even though motion is not stopped, killed, or paused, so dont know how important to pause motion.

And at night, no advantage to pause motion as it is so dark, the camera can see any motion anyway. But if someone came by with a light, then motion is running and will record pics.
I do not use cron or motion so I have no real world experience in this matters but that too is why it is called testing mode.

I'd keep what you have and put it somewhere safe then start anew rethink how to by using how or the logic that is used for motion, which is it whence on it stays on and just pauses between takes, then try cron without root. first.
you've already got a user attached to the group yes? or how ever you set that part up already.

Cron 15-practical-crontab-examples
http://www.thegeekstuff.com/2009/06/...ontab-examples

Last edited by BW-userx; 07-06-2017 at 12:58 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios web interface stopped working afer I got postfix working erosbach Linux - Newbie 1 03-27-2017 02:39 PM
[SOLVED] Web camera stopped working after upgrading to kernel 3.6.0 usr345 Linux - Hardware 2 10-04-2012 02:38 AM
Web Camera Software metallica1973 Linux - General 4 05-08-2009 08:27 AM
iptables script moved machine, stopped working dwynter Linux - Networking 12 02-05-2008 08:44 AM
USB devices stopped working ... sort of Tino27 Slackware 4 02-02-2007 09:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration