Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-26-2005, 02:30 PM
|
#1
|
|
Member
Registered: May 2005
Posts: 38
Rep:
|
Cron Problems
Does anyone see what I am doing wrong?
The following is a crontab, and it is not working every 5 minutes as it should.
The path is correct.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/where/my/directory/code/perl program.pl testfile.txt
|
|
|
|
07-26-2005, 02:57 PM
|
#2
|
|
Member
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92
Rep:
|
If this is Linux, look to see if there are corresponding entries in /var/log/cron (You probably need to be root to see that file). That logfile may be in a different location on other Unixes.
|
|
|
|
07-26-2005, 03:05 PM
|
#3
|
|
Member
Registered: May 2005
Posts: 38
Original Poster
Rep:
|
It is a unix machine, and if I use the crontab -l - I see my file listed.
|
|
|
|
07-26-2005, 03:26 PM
|
#4
|
|
Member
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92
Rep:
|
Right, but 'crontab -l' only lists your cron table.
/var/log/cron is the cron logfile, and will often tell you if a cronjob actually did run every 5 minutes or not. It is a good place to start.
In addition, you should probably capture the standard output & standard error to a logfile, like this:
Code:
# Executes once every 5 minutes
0,5,10,15,20,25,30,35,40,45,50,55 * * * * date >/tmp/date.log 2>&1
# Executes 6 minutes past the hour
6 * * * * foo >/tmp/foo.log 2>&1
Here is the output in /var/log/cron , which shows that the cronjobs were executed:
Code:
% tail /var/log/cron
Jul 26 13:15:00 devel01 CROND[21951]: (stefanl) CMD (date)
Jul 26 13:19:00 devel01 CROND[21974]: (stefanl) CMD (foo)
The output from the cron commands themselves are in the /tmp/*.log files that I created above:
Code:
% cat /tmp/date.log
Tue Jul 26 13:25:00 PDT 2005
% cat /tmp/foo.log
/bin/sh: line 1: foo: command not found
If you don't do this, then any output from 'perl program.pl testfile.txt' will be sent to you via mail, but if mail is not setup correctly the output will sit in the mail queue forever.
|
|
|
|
07-26-2005, 03:38 PM
|
#5
|
|
Member
Registered: May 2005
Posts: 38
Original Poster
Rep:
|
ok, I understand, and that could be the problem. It is on a school server, and mail is not set up.
So, this is most likely the cause of the problem?
|
|
|
|
07-26-2005, 04:48 PM
|
#6
|
|
Member
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92
Rep:
|
There's a problem with either cron or your script. You need to see both the cron output and the script output to debug this problem.
I suggest printing the standard output & standard error to a logfile, in /tmp or under your home directory with a command like 'perl yourscript.pl textfile.txt > $HOME/yourscript.log 2>&1
Then you can look for errors in in $HOME/yourscript.log . You will probably find the error in $HOME/yourscript.log .
Last edited by stefanlasiewski; 07-26-2005 at 05:07 PM.
|
|
|
|
07-26-2005, 06:26 PM
|
#7
|
|
Senior Member
Registered: Mar 2004
Distribution: Slackware
Posts: 4,282
Rep:
|
Maybe you could replace :
Code:
# Executes once every 5 minutes
0,5,10,15,20,25,30,35,40,45,50,55 * * * * date >/tmp/date.log 2>&1
With :
Code:
# Executes once every 5 minutes
*/5 * * * * date >/tmp/date.log 2>&1
Last edited by keefaz; 07-26-2005 at 06:29 PM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
|
cron problems
|
deadite66 |
Linux - General |
0 |
08-06-2005 06:29 PM |
|
Cron Problems
|
DNAphil |
Linux - Newbie |
1 |
07-12-2005 07:56 AM |
|
problems using cron
|
Mugatu |
Linux - Software |
3 |
02-26-2004 02:15 PM |
|
Cron problems
|
goochable |
Linux - General |
3 |
11-15-2003 08:47 PM |
|
Cron problems
|
goochable |
Linux - Newbie |
3 |
04-17-2001 07:43 AM |
All times are GMT -5. The time now is 12:56 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|