Copy Zoneminder Files From Events Directory

Forum for questions and support relating to the 1.24.x releases only.
Locked
rharjika
Posts: 7
Joined: Tue Nov 22, 2011 5:14 pm

Copy Zoneminder Files From Events Directory

Post by rharjika »

What we want to do is copy the zoneminder jpg files from events directory and its subdirectories to another location what is the best way to achieve this. We have written customized linux scripts to do so but when we execute them in a loop after a while zoneminder stops responding or rather stops storing images in its directory. Following is the copy code we are executing:


#!/bin/bash
j=0
while [ 1 ]
do
echo Process > /home/user1/runprocess.out
for i in `find /usr/share/zoneminder/events/1/ -name *ana*.jpg`
do
rm $i
echo $i removed
done
for i in `find /usr/share/zoneminder/events/1/ -name *c*.jpg`
do
fname=`basename $i`
echo $fname
mv $i /home/user1/Axis1$fname
echo $i Copied
done
done

Thanks for your time and response.......
alf
Posts: 41
Joined: Wed Jun 17, 2009 6:13 pm

Re: Copy Zoneminder Files From Events Directory

Post by alf »

Remove the loops and use a cron script?


crontab - e

something like

* 1 * * * * cp /some/directory/*jpg* /some/other/directory
1 1 * * * * echo "somethiongs done"
* 2 * * * * cp /some/directory/*jpg* /some/other/directory
1 2 * * * * echo "somethiongs done"
User avatar
eracc
Posts: 84
Joined: Wed Mar 08, 2006 3:26 pm
Location: USA

Re: Copy Zoneminder Files From Events Directory

Post by eracc »

rharjika wrote:What we want to do is copy the zoneminder jpg files from events directory and its subdirectories to another location what is the best way to achieve this. We have written customized linux scripts to do so but when we execute them in a loop after a while zoneminder stops responding or rather stops storing images in its directory. Following is the copy code we are executing:

Code: Select all

#!/bin/bash
j=0
while [ 1 ]
do
        echo Process > /home/user1/runprocess.out
        for i in `find /usr/share/zoneminder/events/1/ -name *ana*.jpg`
        do
                rm $i
                echo $i removed
        done
        for i in `find /usr/share/zoneminder/events/1/ -name *c*.jpg`
        do
                fname=`basename $i`
                echo $fname
                mv $i /home/user1/Axis1$fname
                echo $i Copied
        done
done
Thanks for your time and response.......
I put the script in 'vim' and cleaned up the formatting, then put it back in a set of Code tags for you.

You are not copying files, you are moving files. Plus you appear to be doing this outside of ZM, which I would expect to break things in ZM. If you want to copy then you should replace this line ...

Code: Select all

mv $i /home/user1/Axis1$fname
... with this line:

Code: Select all

cp $i /home/user1/Axis1$fname
I would also completely remove this section:

Code: Select all

        for i in `find /usr/share/zoneminder/events/1/ -name *ana*.jpg`
        do
                rm $i
                echo $i removed
        done
Then set up a filter or filters inside ZM to manage removal of events and files.

All that said, why exactly are you moving the files at this point? Perhaps we can help you come up with a way to do what you want that does not break ZM. :)
Locked