Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
20.9.2014 - We have just updated our course layouts and descriptions and added our 2015 schedule.

crontab beginner

Posted by dabbler (leah), 23 January 2004
Hi,
I've been venturing into the crontab arena a bit, I have a stats application that I need to run daily to purge the server access log file.

In telnet, I edited my crontab via:
crontab -e

I braved vi, (with a vi command listing in an alternate window ) and I have this in my crontab listing:
Code:
0 2 * * * /home/path/to/stats.pl?update=1



Now I have gotten an email with a cron error message, stating no such file or directory. I am absolutely certain of the path. Is it the update value foiling my task?

Posted by admin (Graham Ellis), 24 January 2004
Basically, yes, the update value is fooling it as you suggest. After the last of the five values, you need a space followed by the command you would run at the command line, which is the name of the program followed by a space followed by other parameters.   The ?name=value notation is the way that information is passed into a script when it's run via CGI and a web page not how it's done from the command line ....

If the script you're trying to run has been written for command line use as well as CGI use, you'll probably find separate help documentation telling you how to run it from the command line ... if not, it's likley that you'll need to do some work on the script if you want to use it via crontab.

The best way to test a job that you will be running in crontab is to type the line (minus the five time fields) at the command prompt in telnet and make sure it works there ... then you're not into a cycle of crontab edit / wait.

One other gem with crontab - ensure you don't have any blank lines in the file you're editing.  If you do it can cause problems.



Posted by dabbler (leah), 24 January 2004
on 01/24/04 at 04:36:28, Graham Ellis wrote:
Basically, yes, the update value is fooling it as you suggest. After the last of the five values, you need a space followed by the command you would run at the command line, which is the name of the program followed by a space followed by other parameters.   The ?name=value notation is the way that information is passed into a script when it's run via CGI and a web page not how it's done from the command line ....

If the script you're trying to run has been written for command line use as well as CGI use, you'll probably find separate help documentation telling you how to run it from the command line ... if not, it's likley that you'll need to do some work on the script if you want to use it via crontab.


Ah-ha, made perfect sense and I've found the command line portion of the documentation. Fixed that, and it still wasn't happening....

Quote:
One other gem with crontab - ensure you don't have any blank lines in the file you're editing.  If you do it can cause problems.



Well there ya go, that sorted it right out.

Quote:
The best way to test a job that you will be running in crontab is to type the line (minus the five time fields) at the command prompt in telnet and make sure it works there ... then you're not into a cycle of crontab edit / wait.


Thank you for that tip as well. Now that I'm more comfortable with cron, I won't hesitate to use it for other things if it can make my life simpler.

Have a great weekend sir.


Posted by admin (Graham Ellis), 24 January 2004
on 01/24/04 at 13:11:28, leah wrote:
Have a great weekend sir.


Ooh - that's far too formal - always makes me slightly nervous to be called "sir" rather than "Graham".  Perhaps a Brit thing?

Glad we got crontab sorted.  Have a good weekend too ... greetings from Minneapolis / St Paul airport [Don't ask   ]

Posted by dabbler (leah), 25 January 2004
on 01/24/04 at 21:29:01, Graham Ellis wrote:
Ooh - that's far too formal - always makes me slightly nervous to be called "sir" rather than "Graham".  Perhaps a Brit thing?



Purely a strong respect for superior knowledge Graham.




This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho