View Full Version : Anyone using crontab???
A call for help!
Is anyone - or has anyone ever used the crontab file here at PowWeb?
I've tried everything I can find, but searching for general cron information doesn't mean it will work here at PowWeb.
I don't want to mess up the server, I don't want to weaken the security set in place. I just want to utilize the crontab in a way that will conform to PowWeb's method of operations.
Specifically I would like to see example(s) of crontab files that have worked here, and maybe an example of the file(s)it executed.
Please help me.....
Writing a script to track time just so I can email a data file once every 24 hours would be a waste of system resources. This is a job for the cron. Please PowWeb help me or tell me to move to another host, so I won't spend another week on this.
Thank you,
Check out this thread:
http://forum.powweb.com/showthread.php?s=&threadid=1102
Jami,
I haven't seen anything from you to indicate that you have succeeded in getting your cron job to run. Just to check it out I have put together a very simple cron job that runs a script and a crontab entry to verify that it is running. Here they are:
testcron.sh:
#!/bin/sh
/bin/date >>/www/k/kriviere/logs/cron.log
crontab:
4,9,14,19,24,29,34,39,44,49,54,59 * * * * /www/k/kriviere/etc/testcron.sh >>/www/k/kriviere/logs/cron.out 2>>/www/k/kriviere/logs/cron.err
Note that the crontab entry only has one line in it, even if it looks like it has wrapped as you read it in this forum. Also, of course, you will need to change references from my directories to your own directories.
This gives me a simple script that can run every five minutes all day long. Each time it runs it will append its output to the indicated log files. Note that as long as the script runs smoothly the cron.out and cron.err files will have nothing in them. With this in place I can update testcron.sh to be any shell script I am trying to test and within five minutes cron will have attempted to run it (once it has picked up the crontab file at midnight) so I can check my logs for errors or results and make corrections and try again. This could have been a perl script (or even php as you found a reference about) or it could have been any compiled program. Personally, I like to have shell scripts in my crontab that then run my programs. This allows me to change directories, set environment variables, or any number of other things to set up the conditions that my program needs to work.
Note that I have given explicit paths for my programs and log files. You could play around with the paths on your commands, scripts, or log files but the possibility exists that if you make a mistake and reference a path that doesn't exist then nothing would get executed or else nothing logged (depending on where the mistake in the path specification was) as cron might not be able to find the command to execute or it might not be able to open the output file. For myself, complete paths are the surest way to make a cron job work unless you are certain you understand what the relative paths will be from whatever state your job is initialized in when cron kicks it off.
With an approach like this, redirecting both stdout and stderr to be appended to log files you should be able to get some results as to what your job is doing and what kind of errors you might be encountering.
Good luck!
-J. Kenneth Riviere
jtucker135
2-5-02, 03:29 AM
thanks. the path info on the prior thread was ambiguous. This helped.
Thanks for the detail.... it turned out that I was overlooking the leading / in my full server path - Arrrrgggg.
Starr, finally pointed this out to me. So I changed it and everything works.
I tried something I read posted by Starr to get cron error messages using .forward, but it never worked. So I'm going to use your suggestion above.
Also, where you split up the minutes - listing them out with commas in between, I don't know if you know it but you can use this instead (when you want matching time blocks like every 5 minutes).
*/12 * * * * /www/a/user/cgi-bin/file.php
The */12 says 60minutes/12 = 5 this will execute every five minutes :-)
Of course you would still use the commas if you wanted ill-regular blocks of time.
Thanks for all your hard work on this,
Jami
I'm glad you were able to get it working. Sometimes it helps to have someone else look at it. Thanks for the tip about the */12, I was unaware of that option.
-JoKeR
The dash - is another you can use, like this:
5 * * * 1-5 /www/a/user/etc/file.cgi
This would execute 5 minutes after every hour on Monday - Friday.
Enjoy!
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.