LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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



Reply
 
Search this Thread
Old 07-26-2005, 03:30 PM   #1
eagle683
Member
 
Registered: May 2005
Posts: 38

Rep: Reputation: 15
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
 
Old 07-26-2005, 03:57 PM   #2
stefanlasiewski
Member
 
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92

Rep: Reputation: 16
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.
 
Old 07-26-2005, 04:05 PM   #3
eagle683
Member
 
Registered: May 2005
Posts: 38

Original Poster
Rep: Reputation: 15
It is a unix machine, and if I use the crontab -l - I see my file listed.
 
Old 07-26-2005, 04:26 PM   #4
stefanlasiewski
Member
 
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92

Rep: Reputation: 16
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.
 
Old 07-26-2005, 04:38 PM   #5
eagle683
Member
 
Registered: May 2005
Posts: 38

Original Poster
Rep: Reputation: 15
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?
 
Old 07-26-2005, 05:48 PM   #6
stefanlasiewski
Member
 
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92

Rep: Reputation: 16
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 06:07 PM.
 
Old 07-26-2005, 07:26 PM   #7
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
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 07:29 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cron problems deadite66 Linux - General 0 08-06-2005 07:29 PM
Cron Problems DNAphil Linux - Newbie 1 07-12-2005 08:56 AM
problems using cron Mugatu Linux - Software 3 02-26-2004 03:15 PM
Cron problems goochable Linux - General 3 11-15-2003 09:47 PM
Cron problems goochable Linux - Newbie 3 04-17-2001 08:43 AM


All times are GMT -5. The time now is 04:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration