Page 1 of 1

[SOLVED] 1.25 crontab issues

Posted: Thu Jul 12, 2012 7:49 am
by Jeffrey
Hi people,

I'm having a problem at the moment. I followed the FAQ for using crontab and using another tutorial on the internet to come up with job to start motion detection when it's 17:00 and it stops motion detection on 8:00 in the morning and also start motion detection again when it's weekend.

This is what I came up with :

0 8 * * 1-5 /usr/local/bin/zmpkg.pl MotionOff
0 17 * * 1-5 /usr/local/bin/zmpkg.pl MotionOn
* * * * 0,6 /usr/local/bin/zmpkg.pl MotionOn

I saved this but when I checked back it didn't start motion detection? I hope you guys can help us with this. I'm open for suggestions. Also we are using Ubuntu 11.10. Please note that I'm not a linux expert haha.

Thanks in advance :]

Re: 1.25 crontab issues

Posted: Thu Jul 12, 2012 12:50 pm
by PacoLM
Stupid question...Have you previously saved (in Zoneminder) the states MotionOn and MotionOff???

Re: 1.25 crontab issues

Posted: Thu Jul 12, 2012 1:12 pm
by Jeffrey
Of course I did save the states :]

Re: 1.25 crontab issues

Posted: Fri Jul 13, 2012 6:38 pm
by mythedoff
Did you?

Code: Select all

sudo crontab -e

Re: 1.25 crontab issues

Posted: Mon Jul 16, 2012 6:41 am
by Jeffrey
mythedoff wrote:Did you?

Code: Select all

sudo crontab -e
Yes, I did. I checked again at the customer just a moment ago and saw that the test that I put in worked just fine. The motion goes off at 8:00 and turn back on at 17:00 so the problem is in the lines.

I used this in the weekend to check the result out.

Code: Select all

0 8 * * * /usr/local/bin/zmpkg.pl MotionOff
0 17 * * * /usr/local/bin/zmpkg.pl MotionOn
And this works perfectly but it is not what I want. I want it to turn off the motion detection at 8:00 to 17:00 and then turn it back on. But also turn on motion detection when it's a weekend.

Thanks in advance :]

Re: [UNSOLVED] 1.25 crontab issues

Posted: Wed Jul 18, 2012 8:08 am
by Jeffrey
I'm still in a need of help? Can't somebody help me with this?

Re: [UNSOLVED] 1.25 crontab issues

Posted: Thu Jul 19, 2012 8:50 pm
by mythedoff
Maybe some additions to each line.

Like:

Code: Select all

0 8 * * 1-5 /usr/local/bin/zmpkg.pl MotionOff > /somedirectory/stdout.log 2>/somedirectory/stderr.log

Re: 1.25 crontab issues

Posted: Fri Jul 20, 2012 3:34 am
by Christo
Jeffrey wrote:
mythedoff wrote:Did you?

Code: Select all

sudo crontab -e
Yes, I did. I checked again at the customer just a moment ago and saw that the test that I put in worked just fine. The motion goes off at 8:00 and turn back on at 17:00 so the problem is in the lines.

I used this in the weekend to check the result out.

Code: Select all

0 8 * * * /usr/local/bin/zmpkg.pl MotionOff
0 17 * * * /usr/local/bin/zmpkg.pl MotionOn
And this works perfectly but it is not what I want. I want it to turn off the motion detection at 8:00 to 17:00 and then turn it back on. But also turn on motion detection when it's a weekend.

Thanks in advance :]
Hello,

Your requested timetable to run these states can be done to add a crontab for each timeframe.

If you don't understand the way crontabs are used, try to do this with the help of the Webmin calender interface.

Goed luck and regards, Christo

Re: 1.25 crontab issues

Posted: Fri Jul 20, 2012 6:51 am
by Jeffrey
Your requested timetable to run these states can be done to add a crontab for each timeframe.
You might wanna explain this more for me. Do you mean that adding it for every hour etc ?

Re: 1.25 crontab issues

Posted: Fri Jul 20, 2012 10:24 am
by Christo
Jeffrey wrote:
Your requested timetable to run these states can be done to add a crontab for each timeframe.
You might wanna explain this more for me. Do you mean that adding it for every hour etc ?
Hello,

No, not for every hour!!

Example:
If you like to have a different runstate for weekdays and weekends, you should make separate crontabs.

As suggested.. install webmin and you will get my point!!
Webmin offers a visual timetable, and I am sure that youll get my point.

If you don't succeed, you can drop me a line with the exact timescedule(s) that you want!

Good luck!!

Re: [SOLVED] 1.25 crontab issues

Posted: Wed Jul 25, 2012 8:54 am
by Jeffrey
I'm testing a new configuration as we speak. I tested the crontab that I posted in the beginning and it seems to work.

Notes of what I did to make it work for future reference.

1 : Check if the time and/or timezone is correctly configured on the computer. (This was probably the problem)

2 : I tested the motion detection code in the terminal before applying to the crontab.

3 : I tested the wiki crontab configuration. (Just to test that it did work)

4 : I edited it back to my crontab configuration in the opening post to config it as I needed it to be.

3 : Double checked in the crontab for uppercase input and if so change it. (This can vary per computer) (This was probably the problem)

There was no need to install webmin after all and my first configuration was in the end just working fine.

Thanks for your attempts to help me guys,

Jeffrey

Re: [SOLVED] 1.25 crontab issues

Posted: Wed Jul 25, 2012 10:29 pm
by mythedoff
Glad you figured it out. Had me thinking.
FWIW, the third line of your crontab will run every minute.