Resetting Event Number??
Resetting Event Number??
Hello,
How would I reset the event count back down to 0? Or any number for that matter?
Thanks,
Alison
How would I reset the event count back down to 0? Or any number for that matter?
Thanks,
Alison
Debian 5.0 Lenny (no GUI) ('Standard' Installation Only, No Extras)
P4HT-3.0Ghz, 2GB RAM
Logitech QuickCam E3500 (remote)
P4HT-3.0Ghz, 2GB RAM
Logitech QuickCam E3500 (remote)
-
- Posts: 7
- Joined: Thu Jun 11, 2009 3:20 am
Resetting Event Number??
I too am interested in doing this.
When you say "delete all events", I would do this through the web interface, correct?
Could you elaborate on clearing the mysql events table? (I have zero experience w/ mysql).
Also, even if you do these things you're still left with the images right? Can I simply rm these images w/o causing any problems?
thanks,
eric
When you say "delete all events", I would do this through the web interface, correct?
Could you elaborate on clearing the mysql events table? (I have zero experience w/ mysql).
Also, even if you do these things you're still left with the images right? Can I simply rm these images w/o causing any problems?
thanks,
eric
Re: Resetting Event Number??
No you lose all the events by dumping the table.zappbrannigan wrote:I too am interested in doing this.
When you say "delete all events", I would do this through the web interface, correct?
Could you elaborate on clearing the mysql events table? (I have zero experience w/ mysql).
Also, even if you do these things you're still left with the images right? Can I simply rm these images w/o causing any problems?
thanks,
eric
The event ID's are tracked by the database using the auto increment setting. If there is ever a duplicate the SQL DB would fall flat on its face. So there is no way to retain data and reset the count.
-
- Posts: 7
- Joined: Thu Jun 11, 2009 3:20 am
Re: Resetting Event Number??
If the images are deleted, that's okay.
The question still stands, how do I zero the event count?
TIA,
eric
The question still stands, how do I zero the event count?
TIA,
eric
Drop and recreate the events table.
Assuming your db is named ZM:
The necessary disclaimer:
You are about to remove and forever lose your events. This may or may not work for you. No one can be held accountable should you follow these instructions. It is up to you to determine how your system is configured and the appropriate syntax to accommodate that configuration.
With that being said, this should work unless you have done something weird and also assumes you have named the database "zm";
There are a few assumptions made but this is the basics of it. It might vary a bit according to your distro but not by much.
Assuming your db is named ZM:
The necessary disclaimer:
You are about to remove and forever lose your events. This may or may not work for you. No one can be held accountable should you follow these instructions. It is up to you to determine how your system is configured and the appropriate syntax to accommodate that configuration.
With that being said, this should work unless you have done something weird and also assumes you have named the database "zm";
Code: Select all
# /etc/init.d/zoneminder stop
# mysqldump -d zm Events > events_table.sql
# mysql zm
mysql> DROP TABLE Events;
mysql> exit
# mysql zm < events_table.sql
# /etc/init.d/zoneminder start
-
- Posts: 7
- Joined: Thu Jun 11, 2009 3:20 am
Re: Resetting Event Number??
Well, nothing seems to have been broken, however...
It did purge all the image files which I did expect but the ID number wasn't reset. (If you're in "record" mode and you open a watch window there's a list of events each with an ID number. I was hoping to reset that number but no such luck.)
Any ideas?
TIA,
eric
BTW, for my or anyone else's future reference, the idea of the previous code snippet is: make a backup of zm's Events table, but without the table's data. Then from within mysql, delete the Events table, then restore the previously backed up, now empty, table.
It did purge all the image files which I did expect but the ID number wasn't reset. (If you're in "record" mode and you open a watch window there's a list of events each with an ID number. I was hoping to reset that number but no such luck.)
Any ideas?
TIA,
eric
BTW, for my or anyone else's future reference, the idea of the previous code snippet is: make a backup of zm's Events table, but without the table's data. Then from within mysql, delete the Events table, then restore the previously backed up, now empty, table.
Okay wasn't sure if the auto numbering would carry over, seems that it does so you will need to add an instruction before exiting mysql and starting ZM:
Alternatively, you can also use truncate table as it will reset the auto increment number as well.
http://dev.mysql.com/doc/refman/5.0/en/truncate.html
Code: Select all
ALTER TABLE Events AUTO_INCREMENT = 1;
http://dev.mysql.com/doc/refman/5.0/en/truncate.html
-
- Posts: 7
- Joined: Thu Jun 11, 2009 3:20 am
Well, that seems to have done it. Thanks.cordel wrote: Alternatively, you can also use truncate table as it will reset the auto increment number as well.
http://dev.mysql.com/doc/refman/5.0/en/truncate.html
Just to tie everything up nice and neat:
Code: Select all
# /etc/init.d/zoneminder stop
# mysql zm
mysql> TRUNCATE TABLE Events;
mysql> exit
# /etc/init.d/zoneminder start
not necessary. Is that correct?
Thanks again,
eric
You would still likely need to dump the events. Mysql I believe will pick up from the highest ID in the table, if it does not, then you risk it creating a conflict that would bring down the table and the server.
If you have the inclination to test it out, by all means please do as I would be interested myself.
If you have the inclination to test it out, by all means please do as I would be interested myself.
Is this working without any negative consequences?zappbrannigan wrote:Well, that seems to have done it. Thanks.cordel wrote: Alternatively, you can also use truncate table as it will reset the auto increment number as well.
http://dev.mysql.com/doc/refman/5.0/en/truncate.html
Just to tie everything up nice and neat:It looks like the mysqldump and the restoring of the dump file areCode: Select all
# /etc/init.d/zoneminder stop # mysql zm mysql> TRUNCATE TABLE Events; mysql> exit # /etc/init.d/zoneminder start
not necessary. Is that correct?
Thanks again,
eric
-
- Posts: 7
- Joined: Thu Jun 11, 2009 3:20 am
I just tried it, seems to have worked fine.psyhomb wrote:Is this working without any negative consequences?zappbrannigan wrote:Well, that seems to have done it. Thanks.cordel wrote: Alternatively, you can also use truncate table as it will reset the auto increment number as well.
http://dev.mysql.com/doc/refman/5.0/en/truncate.html
Just to tie everything up nice and neat:It looks like the mysqldump and the restoring of the dump file areCode: Select all
# /etc/init.d/zoneminder stop # mysql zm mysql> TRUNCATE TABLE Events; mysql> exit # /etc/init.d/zoneminder start
not necessary. Is that correct?
Thanks again,
eric
-
- Posts: 42
- Joined: Wed Mar 05, 2008 10:33 pm
- Location: Stanford-Le-Hope, Thurrock, Essex
I second that
Seems to be working fine on my test systems too. Will soon invoke it on my live ones.
J
J
possible Daily Honor Points...i mean....clean up script....
so, what if we put the code into a shell script and run it as a crontab job, say, at midnight?!?!
(begin code)
!#/bin/bash/
echo "TRUNCATE TABLE Events;" > /home/USERNAME/zmsql.sql
/etc/init.d/zoneminder stop
mysql -uROOT -pPASSWORD use zm << zmsql.sql
/etc/init.d/zoneminder start
(end code)
then set up a crontab that uses this?
hope this helps....
(begin code)
!#/bin/bash/
echo "TRUNCATE TABLE Events;" > /home/USERNAME/zmsql.sql
/etc/init.d/zoneminder stop
mysql -uROOT -pPASSWORD use zm << zmsql.sql
/etc/init.d/zoneminder start
(end code)
then set up a crontab that uses this?
hope this helps....