Page 1 of 1
Run filter after a certain time of day
Posted: Fri Oct 14, 2022 8:15 am
by KaiserPinguin
Due to local laws we are required to purge surveillance videos after a period of max. 72 hours. This is the time frame in which we are able to detect any vandalism or theft (which is the purpose for our video surveillance). During extended weekends e.g. over the easter holidays this time frame is of course longer. Now it is fairly easy to have ZoneMinder purge unarchived videos after 3 days, the question is how do I prevent this filter from running during holidays?
I already have two runstates, nighttime and daytime (the monitors are set to modect during nighttime and to monitor during daytime). On weekdays I use cron to switch between nighttime and daytime using a shell script that checks for holidays. My initial intuition was to use the runstate as a filter condition which would prevent ZoneMinder from deleting stuff during the holidays. But after a long weekend the action would still run and purge events BEFORE any staff members arrive. Unfortunately the system time is no filter condition. Does anybody have an idea how to delay the filter until after 3:00 pm or so? Or is there a way to use a cronjob to trigger the filter?
Re: Run filter after a certain time of day
Posted: Fri Oct 14, 2022 12:58 pm
by iconnor
You can use cron job to run the filter. Don't check the run in background box .. then in cron job run zmfilter.pl --filter_id=[whatever the id is]
You could also sponsor the addition of the needed conditions in the filters...
Re: Run filter after a certain time of day
Posted: Sat Jan 27, 2024 12:21 am
by denver_compdoc
This is an old thread, I know, but I'm running zmfilter.pl in crontab to remove events with fewer than a couple of alarm frames, and I cannot for the life of me get it to output the results to a log. A log is not critical, but I'm just wanting to see that the filter is working. Any hints about how to write a line in crontab that will output to a log? Thanks.
Re: Run filter after a certain time of day
Posted: Sat Jan 27, 2024 5:45 pm
by mikb
denver_compdoc wrote: ↑Sat Jan 27, 2024 12:21 am
This is an old thread, I know, but I'm running zmfilter.pl in crontab to remove events with fewer than a couple of alarm frames, and I cannot for the life of me get it to output the results to a log. A log is not critical, but I'm just wanting to see that the filter is working. Any hints about how to write a line in crontab that will output to a log? Thanks.
At the simplest, if zmfilter.pl writes output to stdout, it would be mailed to the user that invoked it from cron.
Or, you could redirect it's output to a logfile yourself in cron, with
Code: Select all
/path/to/zmfilter.pl --filter_id=myfilter >> /path/to/logfile.txt
... which would append endlessly to that file. Trimming/rotating that log file would be up to you to sort out as needed.
One option -- which I would do -- is to run a script of your own making from crontab. i.e. not call zmfilter direct.
Then, you can log whatever you want just before, during (if it outputs things to stdout), or after. Lots more options ...
e.g.
Code: Select all
#!/bin/tcsh
echo -n "About to do a thing at "
date
/path/to/zmfilter.pl --filter_id=myfilter
echo -n "I did the thing at "
date
Now, put a call to
Code: Select all
/usr/local/bin/yourscript >> /usr/local/etc/yourlogfile.txt
into crontab and you can log all sorts of stuff.
Re: Run filter after a certain time of day
Posted: Sun Jan 28, 2024 8:24 pm
by iconnor
Which user are you running it as? zmfilter normally runs as www-data, and should log to /var/log/zm/zmfilter_[filterid].log
Re: Run filter after a certain time of day
Posted: Sun Feb 04, 2024 1:44 am
by denver_compdoc
I stopped trying with cron and enabled the filter to run in the background. It took some time, like maybe one or two days before it began logging to zmfilter_4.log, but now it does.