I've been using ZM1.24x at the high school I work at for a couple of years now. We rely so much on the cameras that we now have a script that generates a video for "yesterdays activity" for every camera.
I know there have been posts on this, and I've already used the code and modified it successfully for a working script. The scripts I have work perfectly when I run them from the terminal (debian 6 logged in a root). But when I try to schedule them from cron they fail.
I know that 99% of cron errors have to do with full paths and permissions, but I'm confident this is not the problem in my case.
I have been working on this now for about 1 week and to cut a long story short, I've got the problem down to a weird spot in my script.
I've cut the script down to get you experts to help me.
Here is a script that highlights my problem: (I've put the line numbers in myself for reference)
---------------------------------------------------------------------------------------------------------
Code: Select all
1 # !/bin/bash
2 cd /root
3 logger "11111111111111111111111 1111111111111111111111111111"
4 # cameraList=(`ls /var/cache/zoneminder/events/ | grep '[A-Z]'`) 2>/dev/null || die "Failed to open file"
5 cameraList=(`ls /var/cache/zoneminder/events/ | grep '[A-Z]'`)
6 #cameraList=(Peter Paul Mary)
7 echo ${cameraList[0]}
8 touch /tmp/${cameraList[0]}
9 logger "222222222222222222222 222222222222222222222222"
When I run the script from the terminal I get no problems. She this pic 1 script
When I run it from a cron job it dies. She this jpg attached She this pic 2 script
I've narrowed it down to the creation of the array in line 5. I know line 5 works. In fact even if I rem out line 5 and unrem line 6 the same thing happens. see the 2ns jpg above, the log file part.
I'm stuck and would like my script to run
Please note again that to save time I've only shown a portion of my working script as it highlights the problem
thanks
Sam
The error