View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 8 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Mon Apr 16, 2007 5:32 pm 
Offline
Joined: Wed Feb 15, 2006 1:15 pm
Posts: 9
I use motion in r5e50 to capture input from a security camera. Motion creates a new movie file every time there is a gap of more than 1 minute between detected motion. At the end of the day, I have a bunch of different movie files that I want to combine into one.

I use the following script to combine the files:

#!/bin/sh
DAY=`date '+20%y%m%d'`
mencoder /myth/motion/*-$DAY*.avi -noidx -o /myth/motion/$DAY.avi -ovc copy -oac copy

I have found that this script works great when run from the command line. It is common for this script to take several minutes if there are a lot of files to process. When I call it via cron, I apparently run into some kind of resource limitation if there are too many files and not all of the movie files are processed. I cannot find any documentation on these limitations within cron, or how to change them (if that is indeed the problem).

Do any of you have pointers to information on this aspect of cron?

Thanks,

-Jeff


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 7:19 am 
Offline
Joined: Tue Apr 13, 2004 6:51 pm
Posts: 890
Location: Groton, MA
here are a couple cron pointers.

1) First and most importantly, the shell environment that the cron script is executing is does NOT have the environment vars that are set within a login shell. you may want to execute the following from a login shell and from the cron'ed script and look for settings that may effect the processing. you may need to set them in the croned script
Code:
% env > env.list


2) a way to debug cron issues...within the cronfile, at the end of the command add this:
Code:
> /tmp/cron.messages 2>&1

for example
Code:
* * * * * cronScript > /tmp/cron.messages 2>&1

after execution, any stdout or stderr message will be in /tmp/cron.messages

here is a wiki link that details output redirection
http://knoppmythwiki.org/index.php?page=IORedirection

_________________
R5F1 - Dell P4 2.4Ghz 500MB - PVR250 x 2 - GeForce FX 5200 - Onboard sound/NIC 80GB ATA/250GB ATA/400GB SATA


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 8:58 am 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi
If one were to run the cron task as a user would it use the environment of that user?

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 11:26 am 
Offline
Joined: Wed Feb 15, 2006 1:15 pm
Posts: 9
There are definitely differences in the environments, but I didn't notice anything that would limit the runtime or file size:

Cron environment
SHELL=/bin/sh
PATH=/usr/bin:/bin
PWD=/root
SHLVL=1
HOME=/root
LOGNAME=root
_=/usr/bin/env

Normal shell environment
TERM=vt100
SHELL=/bin/bash
SSH_CLIENT=192.168.1.100 40214 22
OLDPWD=/root
SSH_TTY=/dev/ttyp2
USER=root
MAIL=/var/mail/root
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games
KRP_DIR=/usr/lib/krp
PWD=/root
LANG=C
SHLVL=1
HOME=/root
LANGUAGE=us
LOGNAME=root
SSH_CONNECTION=192.168.1.100 40214 192.168.1.106 22
_=/usr/bin/env

I dumped the output of the cron job to a log file as suggested, the encoding job simply gets cut off before completion. I added a 'date' command at the beginning and end of my script to see how long it is running, it only goes for 8 seconds.

So here is an interesting wrinkle: If I run the script from the command line, it works just fine *unless* I dump the log messages to a file like this:

# crontest.sh > logfile.txt

When I dump it to a file, I get the exact same behavior as with cron, the processing stops after about 8 seconds. I thought maybe it was some weird thing with too much output from mencoder, so I added the -quiet switch. Now it is limited to 8 seconds of execution whether I'm dumping the output messages to a file or not.

Someone is going to read this and know exactly what is going on, but I'm clueless.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 12:06 pm 
Offline
Joined: Tue Apr 13, 2004 6:51 pm
Posts: 890
Location: Groton, MA
Mike,

NO! that was my point. if you want the same env, you need to source the approproiate env file for the shell. (.chsrc, .profile .kshrc....)

this can be done in the script or in the crontab

Code:
* * * * * (. .profile;command)

_________________
R5F1 - Dell P4 2.4Ghz 500MB - PVR250 x 2 - GeForce FX 5200 - Onboard sound/NIC 80GB ATA/250GB ATA/400GB SATA


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 12:37 pm 
Offline
Joined: Tue Apr 13, 2004 6:51 pm
Posts: 890
Location: Groton, MA
how about this..

Code:
# script > /dev/null

_________________
R5F1 - Dell P4 2.4Ghz 500MB - PVR250 x 2 - GeForce FX 5200 - Onboard sound/NIC 80GB ATA/250GB ATA/400GB SATA


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 1:30 pm 
Offline
Joined: Wed Feb 15, 2006 1:15 pm
Posts: 9
Dumping to /dev/null doesn't work either. It pretty much boils down to mencoder. Anything I do that suppresses mencoder's ability to dump output to the terminal causes the script to stop short. That even includes using the -quiet, -really-quite, or -msglevel scripts within mencoder (even when running mencoder directly from the command line).

This seems like a mencoder bug to me.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 7:39 pm 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi,

What if you make your script run in the background?
#!/bin/sh
cd /(where ever the script lives so it can find the DAY variable)
DAY=`date '+20%y%m%d'`
/usr/bin/mencoder /myth/motion/*-$DAY*.avi -noidx -o /myth/motion/$DAY.avi -ovc copy -oac copy &

Just some ideas
Mike


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu