LinHES Forums http://forums.linhes.org/ |
|
cron job runtime or resource limitations? http://forums.linhes.org/viewtopic.php?f=5&t=14956 |
Page 1 of 1 |
Author: | jeffwight [ Mon Apr 16, 2007 5:32 pm ] |
Post subject: | cron job runtime or resource limitations? |
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 |
Author: | khrusher [ Tue Apr 17, 2007 7:19 am ] |
Post subject: | |
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 |
Author: | mjl [ Tue Apr 17, 2007 8:58 am ] |
Post subject: | |
Hi If one were to run the cron task as a user would it use the environment of that user? Mike |
Author: | jeffwight [ Tue Apr 17, 2007 11:26 am ] |
Post subject: | |
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. |
Author: | khrusher [ Tue Apr 17, 2007 12:06 pm ] |
Post subject: | |
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)
|
Author: | khrusher [ Tue Apr 17, 2007 12:37 pm ] |
Post subject: | |
how about this.. Code: # script > /dev/null
|
Author: | jeffwight [ Tue Apr 17, 2007 1:30 pm ] |
Post subject: | |
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. |
Author: | mjl [ Tue Apr 17, 2007 7:39 pm ] |
Post subject: | |
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 |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |