View Full Version : Vixie Cron 3.0pl1 now available. Schedule your TiVo tasks.
dtype
07-30-2002, 06:35 PM
There seemed to be a need, so I spent some time with this. Many hours later, I'm happy to present Vixie Cron 3.0pl1, mildly modified and cross-compiled for TiVo.
I'm assuming anyone that cares about this already knows what cron is. I've tried to make installation as easy as possible, while modifying cron's behavior as little as possible. Please read the included README for details.
Please post comments and feedback to this forum.
All of my tivo creations are at
ftp://ftp.dtype.org/pub/tivo/
almontebarnes
07-30-2002, 07:01 PM
Thank you, thank you, thank you. I'm sure AlphaWolf will thank you as well. NoSDD just got that much nicer...
simonp
07-30-2002, 07:30 PM
HOORAY!
JJBliss
07-30-2002, 09:19 PM
Wicked !!!!!!!!
Installed, and sample crontab file executed !!
I may not sleep tonight!!
:D
AlphaWolf
07-30-2002, 10:00 PM
Cool, Ive been getting bored with my tivo recently, guess I have a job to do now :D
Ill work on a nosdd crontab when I get around to it, probably tommorow.
onyx00
07-30-2002, 10:19 PM
What other things besides the no service data download would we want to actually scheduled?
JJBliss
07-30-2002, 10:24 PM
Originally posted by onyx00
What other things besides the no service data download would we want to actually scheduled?
Oh criminey, there's just so much...
noppv.tcl
TivoTitle.tcl
mvchannels.tcl ?
Clearing logs above and beyond those from Tivo:
elseed.log
noppv.log
I can think of all sorts of things.
AlphaWolf
07-30-2002, 10:35 PM
Not to mention fixsub when 3.0 comes out and there is no tclient a la the standalone tivos.
dtype
07-30-2002, 10:59 PM
I see many downloads and one successful use post. Does this mean that others have tried this and made it work?
I'm very interested in comments about my somewhat simple instructions, and any problems people have.
The end of the README should have said something about putting the cron binary somewhere in rc.sysinit, but I sort of assume people figure that part out.
onyx00
08-01-2002, 11:54 AM
I didn't even think of the noppv running; good call.
Logs files are a good point too.
Alpha, already thinking of 3.0 eh? :-)
genericuser
08-03-2002, 02:25 AM
I finally installed this package. Here are a few comments.
I suppose this package is for more advanced users. I knew that I would have to start it in rc.sysinit, so I added a line. Unless you know that, it will be hard to get it automatically started. Actually, I had the rc.sysinit sleep for 3 minutes before starting cron. That way the problem of starting mvchannels while the tivo is booting wont happen.
So it was not too hard to install, but I know unix well. And I know what cron does and where things are supposed to be. A less advanced user may stumble.
The supplied crontab worked spendidly. I currently have two entries in the crontab. One for mvchannels and one for noppv. Here is the interesting part. The entires look like:
*/6 * * * * /hack/mvchannels.tcl -file=/hack/channels.dat > /var/hack/mvch.out
*/15 * * * * /hack/noppv.tcl -7 > /var/hack/noppv.out
So mvchannels runs every 6 minutes and noppv runs every 15. And I can see from the log file in /var/hack/cron that they do. However... The output files that are created in /var/hack are very interesting. They only contain the first few lines of output from the file being run.
e.g. For noppv I get:
noppv tcl script:
Removes PPV flag from existing shows in the Tivo database.
That is all. None of the rest of the output shows up.
I know that cron is running the command like this: sh -c <command> because if I ps auxgww at the right time I can see it go off. So, I tried doing an
sh -c /hack/noppv.tcl -7 > /var/hack/noppv.out
That worked fine and the .out file was complete. So I guess my question is, Where is the output going when the command is run in cron? How come only part of the output is showing up?
The interesting part is that the commands did not seem to run as long as they normally do. Typically noppv takes at least 20 seconds. When I do the ps, I see the command start, but if I do another ps a few seconds later the command is no longer running.
Thanks for the wonderful tool. It simplified my rc.sysinit so much.
genericuser
08-03-2002, 02:44 AM
Now suddenly my log files have a bit more info:
noppv.log:
/var/hack# cat noppv.out
<166>Aug 3 06:45:00 tcl[163]: Tcl created pool of 1458176 bytes
noppv tcl script:
Removes PPV flag from existing shows in the Tivo database.
<134>Aug 3 06:45:02 AttachSharedMemoryFile[163]: Can't open key file /var/tmp/pseudo for attach, errno 2
mvch.out:
/var/hack# cat mvch.out
<166>Aug 3 06:42:00 tcl[145]: Tcl created pool of 1458176 bytes
Input file set to '/hack/channels.dat'
<134>Aug 3 06:42:01 AttachSharedMemoryFile[145]: Can't open key file /var/tmp/pseudo for attach, errno 2
Am I missing this /var/tmp/pseudo file? I can not remember if it was ever in /tmp before. I tried rebooting thinking that might fix it, but it is still showing the same behavior.
genericuser
08-03-2002, 09:20 AM
It does not work (for me). I have a t-60 with a hacked 2.5 on it.
After leaving it running for 6 hours, I came back and was still getting the errors I mentioned about about he pseudo file. I looked at the guide and the channels I have moving in the 2-99 area had a few of them slip back to their original numbers. I waited until 12 after when it says it was running mvchannels. I then checked the guide and the channels were not moved back to their new positions. I then ran mvchannels manually from the shell and it worked fine and the channels moved where they were supposed to.
As a secondary check, I let it hit the :15 after mark when it was supposed to run noppv. This happened. I then ran noppv from the shell and it fixed over 2000 showings.
So... The question becomes where is this pseudo file at?
Dang it! I wish I had access to a cross compiled version of 'find'. That would make locating this file much easier.
Unless my installation is missing something. Can others check their /var/tmp areas and see if this 'pseudo' file exists in it?
I will manually search for it.
mrblack51
08-03-2002, 11:18 AM
dtype: thanks for posting this. i had been trying to get a cron to cross compile off and on for a while, but never quite got there. tried it a couple days ago and it works sweet.
superzap
08-03-2002, 11:23 AM
Can't find a 'pseudo' file here.
Have you tried running a regular bash shell script using Cron?
I suspect there might be some incompatibility with running a tivo shell script like you're trying. Try putting /tvbin/tivosh first on the command line like this:
/tvbin/tivosh /hack/noppv.tcl -7 > /var/hack/noppv.out
You might have to remove the #!/tvbin/tivosh line from the beginning of the script.
genericuser
08-03-2002, 11:46 AM
Well, I encapsulated the script in a file like this:
/var/hack# cat /hack/noppv.sh
#!/bin/bash
/hack/noppv.tcl -7 > /var/hack/noppv.out
Sitting at the bash prompt, I can type /hack/noppv.sh and the .out file appears as expected in /var/hack. Everything works.
So now I change the crontab file to read:
*/15 * * * * /hack/noppv.sh
However, the error remains the same (no pseudo file). I tried touching /var/tmp/pseudo. However, the error simply changes to "ivalid key file". :-)
dtype
08-03-2002, 12:05 PM
Originally posted by genericuser
However, the error remains the same (no pseudo file). I tried touching /var/tmp/pseudo. However, the error simply changes to "ivalid key file". :-)
Keep in mind that cron works from a different working directory than you do. Default directories for search may also be slightly different. Try putting a `cd /your/directory` before running things, to change directories to the place you'd normally run this command. You might also check the script itself to see if it hard codes directories, or just assumes files will be in a current directory.
Cron is probably just running from /var/tmp as a working directory, and looking for the psuedo file in the _current_ directory, not in /var/tmp in particular.
genericuser
08-03-2002, 12:07 PM
Ok, I give up for now. Has anoyone gotten noppv or mvchannels or any tivosh to run through this? If so, what does your crontab entry look like and did you have to change the script at all?
genericuser
08-03-2002, 12:12 PM
dtype,
That file pseudo is not used in the script at all. It is some sort of system thing. Like I said above, now that I have encapsulated the noppv.tcl into noppv.sh, I can be in any directory (/ or /var/hack or wherever) and type /hack/noppv.sh and it executes perfectly fine. <-- Assuming I am sitting at the bash prompt. If I then put a line in crontab to execute the same command (/hack/noppv.sh) it does not work and it complains about the pseudo file.
Have you gotten any interesting scripts to run usin this cron?
I must say cron is trying to execute them, but something happens.
dtype
08-03-2002, 12:25 PM
Originally posted by genericuser
Have you gotten any interesting scripts to run usin this cron?
Someone else will have to help with the noppv scripts. I don't tend to deal with that much. Anyone?
The cron I packaged up is pretty much a straight vixie cron, with the permissions code having been danced around, and directories hard coded to /var/hack for the config files and runtime files.
I suspect that the /var/tmp usage is somewhere in tcl, or elsewhere, if for no other reason than (1) cron doesn't use any temp files, other than crontabs, that I'm aware of and (2) they would be in /var/hack/cron anyway.
It is very possible that because of the way the shell is now non-interactive, or environment variables have changed, the resultant script is getting confused. (I forgot to mention that you might also want to check environment variables, which will also not be set as you might expect.)
If there is anything I can change in cron to make things easier, I will, but I'm not sure what the problem is now. :/ Will need to rely on someone that knows what that pseudo file is.
genericuser
08-03-2002, 12:36 PM
Unfortunately I have no file called pseudo anywhere in my directory structure on this tivo. I believe that SuperZap verified the same thing on his.
I am currently trying to get just a bash script to run. Once that is done, I will move back to the tivosh stuff.
Hmmm... Lets see if I can get the script to run if I pipe out to /dev/null.
dtype
08-03-2002, 12:39 PM
Originally posted by genericuser
Unfortunately I have no file called pseudo anywhere in my directory structure on this tivo. I believe that SuperZap verified the same thing on his.
You wouldn't. If we have verified /var/tmp is not the working directory, the only other reason a file could be there is that it was created at runtime.
I suspect tcl, tivosh, or some script included (maybe even implicitly) is doing this.
superzap
08-03-2002, 12:49 PM
Originally posted by dtype
I suspect tcl, tivosh, or some script included (maybe even implicitly) is doing this. This is what I tried to explain in my 1st post.
genericuser:
Try changing the crontab to
*/15 * * * * /tvbin/tivosh /hack/noppv.tcl -7 > /var/hack/noppv.out
genericuser
08-03-2002, 12:59 PM
SZ,
I tried exactly that line. Same error :-(
superzap
08-03-2002, 01:58 PM
I haven't figured out a solution yet but it seems that tivosh cannot establish a proper environment.
You might see some error messages if you change the line to:
*/15 * * * * /hack/noppv.tcl -7 >> /var/hack/noppv.out 2>&1
I used a simple test TCL script and got this:
(file "/var/hack/testPC" line 52)
WARNING: couldn't scan startup script /tvlib/tcl/tv/tv.ini
WARNING: eval result : can't read "env(TIVO_ROOT)": no such element in array unable to initialize filesystem
while executing
"dbopen"
dtype
08-03-2002, 02:01 PM
If it can't find a TIVO_ROOT environment variable, try this:
At your bash prompt, type `export`, and note the value of TIVO_ROOT. When running tivosh, just append `TIVO_ROOT=/dir/value` to the beginning of the line, or create a separate line in the shell script `export TIVO_ROOT=/dir/value`. This can also be done in the crontab file itself, iirc.
mrblack51
08-03-2002, 02:41 PM
# m h dom mon dow command
5,35 * * * * /var/hack/TivoTitle.tcl -c >> /dev/null
0 8 * * * /var/hack/noppv.tcl -6 >> /dev/null
30 8 * * * /tvbin/rmLogs.tcl >> /dev/null
thats what my crontab looks like, and it seems to run fine. the log does just fine, and it contains:
cron (08/02-06:35:00-828) CMD (/var/hack/TivoTitle.tcl -c >> /var/log/TivoTitle.log)
cron (08/02-07:05:00-901) CMD (/var/hack/TivoTitle.tcl -c >> /var/log/TivoTitle.log)
*system* (08/02-07:19:00-663) RELOAD (/var/hack/etc/crontab)
cron (08/02-07:35:00-966) CMD (/var/hack/TivoTitle.tcl -c >> /dev/null )
cron (08/02-08:00:00-1022) CMD (/var/hack/noppv.tcl -6 >> /dev/null)
cron (08/02-08:05:00-1036) CMD (/var/hack/TivoTitle.tcl -c >> /dev/null )
cron (08/02-08:30:00-1096) CMD (/tvbin/rmLogs.tcl >> /dev/null)
superzap
08-03-2002, 03:02 PM
Are you sure the tcl scripts are actually running properly?
Cron is executing everything I throw at it except anything tcl. The cron log looks ok but errors are occuring in the tcl scripts.
I'm curious to see what you get if you change your /dev/null stdout files to a real file.
genericuser
08-03-2002, 03:23 PM
WOO HOO!! I think I have it. Let me verify WTF I have done.
dtype is absolutely correct. I has to do with the env...
Hold on one second...
genericuser
08-03-2002, 04:00 PM
As dtype stated, it has to do with the environment. By messing around, I got it to work.
Here is what I do:
In /etc/profile (assuming you are using the --login for activating bash) I added two lines as follows:
export > /var/hack/vars
chmod 755 /var/hack/vars
This creates an executable file called vars in /var/hack. This is necessary so you can 'dot' it in in the crontab file so that the environment when jobs run in cron is exactly like it is when you are in the shell.
Now in the crontab my entries look like:
*/6 * * * * . /var/hack/vars ; /hack/mvchannels.tcl -file=/hack/channels.dat > /var/hack/mvch.out 2>&1
*/15 * * * * . /var/hack/vars ; /hack/noppv.tcl -7 > /var/hack/noppv.out 2>&1
So, before you execute the tcl code you create an environment that is tcl friendly.
I have verified that both of the tcl items I am running are now executing correctly (as seen in the .out files). So now I am happy!
MrBlack,
Where did you get the rmLogs.tcl script? I was running logsnull as written by SZ, but now that I have finer control, I want something a bit different.
gosquad
08-03-2002, 04:37 PM
Great job, genericuser.. I wouldn't have thought to try that. Works great now!
Gosquad
superzap
08-03-2002, 05:24 PM
Yes, good work, genericuser and dtype. :D
I put the export > /var/hack/vars in rc.sysinit right before the startup of cron.
superzap
08-03-2002, 05:53 PM
For those who need some documentation on the format of the crontab file entries ===> http://web-design.net/servers/extensions/cron/crontab.5.html
Note: If you want something run at a specific time, make sure you use GMT time (add your specific GMT offset to your zone's time). And don't forget the time cron uses is not adjusted for daylight savings.
NIce work dtype and genericuser
Superzap thanks for the link very helpful.
mrblack51
08-04-2002, 02:02 PM
has anyone else been getting micro skipping when your tivotitle runs with this method? i get an audio skip when mine runs (just a little hickup). skips even if i use:
5,35 * * * * . /var/hack/vars ; nice -n 19 /var/hack/TivoTitle.tcl -c >> /dev/null
ideas?
RUBiK
08-05-2002, 09:16 PM
thanks for cross-compiling this!
i tried a long long time ago to cross-compile about 7 different cron daemons (different variants including vixie, etc.) but gave up since i didn't have time to fix the code but it looks like you've done a nice job and it works great here, so many thanks...
i just stumbled upon this thread, so i haven't had much time to think about the env vars but "dotting" in crontab will work for now...
if i think of better ways to do it, i'll obviously contribute...
the only other thing i have to add here is... those who want/care, can add a 'TZ' environment variable with their timezone value (if you're bothered by cron using GMT times internally)...
in your ~/.bashrc or equivalent, "export TZ=PST8PDT" (i live in LA)... use 'EST5EDT' for eastern timezone, etc...
superzap
08-06-2002, 11:20 AM
See this (http://www.tivocommunity.com/tivo-vb/showthread.php?s=&postid=630289#post630289) for a possible complication for setting TZ variable.
RUBiK
08-06-2002, 12:43 PM
thanks, SZ... i hadn't seen that thread..
very odd... i've seen no internal TiVo clock that ran in GMT/UTC time/date format and i've had that TZ variable set for almost a year now and my DSR6k has never missed a scheduled recording or done any funky stuff that would be time/date related...
one of those YMMV things, i guess? no idea...
but thanks for pointing that out.. if stuff goes screwy (i doubt it... maybe it did with 1.x software?), i'll know one of the things to look into...
genericuser
08-12-2002, 03:32 PM
It has been well over a week now since this has been running on my system and I must say that removing the endlessly looping scripts from rc.sysinit and putting them into cron is a godsend.
I firmly believe that my system runs faster than when I had scripts looping.
Thanks again, dtype.
AlphaWolf
08-19-2002, 08:36 PM
Originally posted by genericuser
It has been well over a week now since this has been running on my system and I must say that removing the endlessly looping scripts from rc.sysinit and putting them into cron is a godsend.
I firmly believe that my system runs faster than when I had scripts looping.
Thanks again, dtype.
hoo-ah, and your little trick you clued earlier works nicely, without it cron causes my tivo to reboot when you use a TCL script that uses a transaction (all of them?)
props
EDIT: after some small trial and error, I found that only these lines from /var/hack/vars thats necessary:
declare -x MFS_DEVICE="/dev/hda10"
declare -x TIVO_ROOT=""
Add the lines:
MFS_DEVICE="/dev/hda10"
TIVO_ROOT=""
above the line that starts with shell in the crontab, and your worries are over, no need for the /var/hack/vars file.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.