LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-01-2004, 05:51 PM   #1
dbc001
Member
 
Registered: Jan 2004
Distribution: Slackware, Ubuntu
Posts: 97

Rep: Reputation: 15
How can I troubleshoot cron problems?


I'm having problems with cron on mandrake 10.0 official.
I'm just trying to run a simple script (called "test-script"):

#!/bin/sh
echo "this is a test" > /var/www/test.txt

here is what my crontab looks like:

08 10 * * * root /root/test-script

which should cause "test-script" to run as root at 10:08 (right?)

at 10:09 this is what the end of /var/log/cron/info looks like:

Nov 28 10:08:00 justice CROND[1419]: (root) CMD (root /root/test-script)
Nov 28 10:08:00 justice CROND[1418]: (root) MAIL (mailed 41 bytes of output but got status 0xffffffff )

so it looks like the script got executed.

but /var/www/test.txt does not exist.

can anyone tell me what i'm doing wrong?

thanks in advance,
dbc

ps: the script runs just fine from the command line:
[root@justice root]# ls -l /root/test-script
-rwxr-xr-x 1 root root 53 Nov 28 10:05 /root/test-script*
[root@justice root]# ls -l /var/www/test.txt
ls: /var/www/test.txt: No such file or directory
[root@justice root]# . test-script
[root@justice root]# more /var/www/test.txt
this is a test
[root@justice root]#

you can see that "test-script" is executable, and that it creates the file when run. but it doesn't look like cron is actually running the script, and i can't find any useful information in the error log (unless maybe i'm looking in the wrong place!)
 
Old 12-01-2004, 06:31 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"the script runs just fine from the command line:"

"so it looks like the script got executed.

but /var/www/test.txt does not exist."

The PATH that cron runs with is pretty skimpy. So cron starts the /root/test-script script and /root/test-script probably fails on "bash command not found" which message is not displayed on the screen. Try setting your PATH in /root/test-script so that the cron demon can find bash and other common commands:

PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
echo "this is a test" > /var/www/test.txt

------------------------------
Steve Stites
 
Old 12-01-2004, 06:54 PM   #3
jonr
Senior Member
 
Registered: Jan 2003
Location: Kansas City, Missouri, USA
Distribution: Ubuntu
Posts: 1,040

Rep: Reputation: 47
You can also set environment variables in your crontab itself, if that is sometimes more convenient.

See

Code:
man 5 crontab
for some good examples.

I set mine to mail results to me, the ordinary user, instead of root, for example, since I'm the only person
using this computer (I hope!).
 
Old 12-02-2004, 03:17 PM   #4
LasseW
Member
 
Registered: Oct 2004
Distribution: Fedora 7, OpenSuse 10.2
Posts: 108

Rep: Reputation: 15
To me it looks like it's trying to start a program called root with your script as parameter. Try to remove the sixth parameter and see what happens. Is there any message in root's mail ? Just type 'mail' as root, don't know what the status code means, though.
 
Old 12-02-2004, 03:32 PM   #5
jonr
Senior Member
 
Registered: Jan 2003
Location: Kansas City, Missouri, USA
Distribution: Ubuntu
Posts: 1,040

Rep: Reputation: 47
Quote:
Originally posted by LasseW
To me it looks like it's trying to start a program called root with your script as parameter. Try to remove the sixth parameter and see what happens. Is there any message in root's mail ? Just type 'mail' as root, don't know what the status code means, though.
From doing a little Googgle searching, I'm willing to bet the status code meant the message couldn't be delivered and delivery would be tried again in the future. I'm wondering if your sendmail is set up and usable? I don't see that you mentioned if you normally use it.
 
  


Reply



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 On
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 eagle683 Programming 6 07-26-2005 06:26 PM
cron problems tassinari Linux - Newbie 8 04-02-2005 10:11 PM
How to troubleshoot linux connectivity problems JJEFF Linux - Networking 11 11-06-2003 11:59 PM
Cron problems goochable Linux - Newbie 3 04-17-2001 07:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:34 PM.

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
Open Source Consulting | Domain Registration