Switch states on schedule?

Forum for questions and support relating to the 1.30.x releases only.
Locked
Avro125
Posts: 21
Joined: Sun Jun 26, 2016 12:39 pm
Location: Canada

Switch states on schedule?

Post by Avro125 »

I'm trying to get ZomeMinder to record a weekly backup generator test, and am trying to use crontab to switch 'states'. ...and am not having much luck.

Remote site, generator status is not monitored at all, so the only way to check to see if the weekly test is happening is to do so visually. The genset is far enough away from the wide-angle camera that motion detection isn't possible. So, I've created a new state in ZM where the camera that looks at the generator is in continuous record mode. I've switched back and forth using the GUI and it functions as desired.

I've created the following in crontab to switch states on Tuesdays to capture the 5-minute test scheduled for 14:45, with a little bit of a buffer on either side.

Code: Select all

43 14 * 1-4,12 2        root    usr/bin/zmpkg.pl GensetTest
52 14 * 1-4,12 2        root    usr/bin/zmpkg.pl Winter
...so, start at 14:43 on Tuesdays in Dec, Jan, Feb, Mar and Apr. Switch back at 14:52.

'Winter' is the normal operating state this time of year. The time shifts by an hour when daylight savings time starts (as the generator clock doesn't adjust itself), and once the snow disappears I move ZM to 'Summer' state. I'll tweak all that once I get things working now, as I've tested this and it does not work. ZM simply coasts through the specified time period and nothing happen. If it was functioning there would be a few continuously recorded events from the one camera.

Any suggestions?
User avatar
snake
Posts: 337
Joined: Sat May 21, 2016 2:20 am

Re: Switch states on schedule?

Post by snake »

See https://wiki.zoneminder.com/Cron for example cron jobs.

You have to run as www-data user to change run states. Also it should be /usr not usr.
Avro125
Posts: 21
Joined: Sun Jun 26, 2016 12:39 pm
Location: Canada

Re: Switch states on schedule?

Post by Avro125 »

Thank you!

Updated the crontab file to adjust for DST and summer/winter. Tested, and it's working well. So as not to leave the bad code here by itself, this is what I've got:

Code: Select all

43 14 * 1,2,12 2        www-data        /usr/bin/zmpkg.pl GensetTest
52 14 * 1,2,12 2        www-data        /usr/bin/zmpkg.pl Winter
43 15 * 3,4 2     www-data     /usr/bin/zmpkg.pl GensetTest
52 15 * 3,4 2     www-data     /usr/bin/zmpkg.pl Winter
43 15 * 5-10 2     www-data     /usr/bin/zmpkg.pl GensetTest
52 15 * 5-10 2     www-data     /usr/bin/zmpkg.pl Summer
43 14 * 11 2     www-data     /usr/bin/zmpkg.pl GensetTest
52 14 * 11 2     www-data     /usr/bin/zmpkg.pl Summer
Doesn't match up 100% with daylight savings time, but close enough for me. At worst, I'd miss one test.
Locked