Run filter after a certain time of day

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
KaiserPinguin
Posts: 2
Joined: Fri Oct 14, 2022 7:47 am

Run filter after a certain time of day

Post 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?
User avatar
iconnor
Posts: 2949
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Run filter after a certain time of day

Post 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...
denver_compdoc
Posts: 8
Joined: Sun Jun 14, 2015 3:32 pm

Re: Run filter after a certain time of day

Post 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.
mikb
Posts: 623
Joined: Mon Mar 25, 2013 12:34 pm

Re: Run filter after a certain time of day

Post 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.
User avatar
iconnor
Posts: 2949
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Run filter after a certain time of day

Post 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
denver_compdoc
Posts: 8
Joined: Sun Jun 14, 2015 3:32 pm

Re: Run filter after a certain time of day

Post 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.
Post Reply