LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-17-2004, 03:00 AM   #1
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Rep: Reputation: 30
Angry crontab does not work need help


HI all

I have been at it for hours testing the bloody thing and still im out of luck.

Anyways I edit crontab using "crontab -e" command as a regular user. I put a simple line in there

50 3 * * * echo "crontab works!!"

When it hits that time the command does not execute. Nothing happens. I already created a /etc/cron.allow and put my username in there. I tried searching the web but all i get is same discussions on how to do crontab. I think im missing something. Btw when I do "crontab -l" I get this buggy thing:
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.6243 installed on Sat Apr 17 03:49:51 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)

So if anyone can shine some light on this matter i will be greatfull. Thanks
 
Old 04-17-2004, 08:14 AM   #2
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
Are the cron service running?
 
Old 04-17-2004, 08:40 AM   #3
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
Also is mail running? Or have you checked your mail? The output of process is mailed to the owner.
 
Old 04-17-2004, 05:05 PM   #4
peter.burton
LQ Newbie
 
Registered: Oct 2003
Location: Reading, Berkshire,England
Distribution: Suse 9.0
Posts: 3

Rep: Reputation: 0
Suggest also that you do not use !!s in an echo as you might upset the default shell.
Try a df command instead of an echo.

Remember all crontab output is mailed to the user if it can.

In a shell window type mail to see your mail.
 
Old 04-17-2004, 05:10 PM   #5
peter.burton
LQ Newbie
 
Registered: Oct 2003
Location: Reading, Berkshire,England
Distribution: Suse 9.0
Posts: 3

Rep: Reputation: 0
One other thing
DO NOT have any blank lines in crontab entries.
So with one command - do NOT finish with a C/R.
 
Old 04-18-2004, 02:13 AM   #6
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Original Poster
Rep: Reputation: 30
Ok so this is what my crontab file looks like and yet it still does not work:


# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.7575 installed on Sun Apr 18 03:05:58 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=username
HOME=/home/username/

7 3 * * * /bin/df

I tried issuing mail command to see if i have any mail... i have no mail

crond service is running and its owned by root. Im out of ideas anything else i could be missing?
 
Old 04-18-2004, 02:14 AM   #7
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Original Poster
Rep: Reputation: 30
btw whats a C/R?
 
Old 04-18-2004, 02:31 AM   #8
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
c/r is carriage return - what you get when you hit <return> or <enter>. Not sure how strict the requirement about c/r's is. The man page in fact says each line must end with a c/r and:

The best choice is to ensure that your crontab has a blank line at the end

Is that the exact output of 'crontab -l'? Your real user name should be in there. Not just 'username'.

Why not try with

7 3 * * * /bin/df > /home/username/test.junk

(change username of course...) so the command has a lasting side-effect.

I recall having similar frustration with cron when I first tried to use it, so don't give up!
 
Old 04-18-2004, 02:48 AM   #9
peter.burton
LQ Newbie
 
Registered: Oct 2003
Location: Reading, Berkshire,England
Distribution: Suse 9.0
Posts: 3

Rep: Reputation: 0
C/R means carriage return. ( the return key )

Only use crontab -e to get the commands into cron.
It is important to not edit the cron files because cron only looks at them
on a reboot.
crontab -e as well as checking your typing also tells cron
about the new command.

If crontab -l shows the new command line then it should work.
( don't do the command too close to current time. cron might not see it in time)

Failing that then find the pid number of cron and try to strace the process
as root and wade through the output...
to find out what is going wrong at the time of cron running your command.

e.g.
su root
...........

pgrep cron
1984

strace -p 1984
...................
..................etc
 
Old 04-18-2004, 08:54 PM   #10
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Original Poster
Rep: Reputation: 30
ok looks like it worked i dont know why though lol. I think I rebooted the system still that is weird. Although when i did reboot the system i took a look into my crontab and it was empty why I dont know so i put in a fresh new line in there tested it with C/R and without and it worked both times. This is just unexplainable no idea what happened.
 
Old 04-18-2004, 08:55 PM   #11
Xris718
Member
 
Registered: May 2003
Location: NYC
Distribution: CentOS
Posts: 261

Original Poster
Rep: Reputation: 30
thanks for all help guys
 
  


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
crontab doesn't work, but everything is set correctly ttilt Linux - General 10 06-16-2005 05:44 PM
work with crontab juanb Linux - General 1 06-05-2004 09:29 AM
crontab ALF Linux - Software 4 12-18-2003 11:10 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM
crontab won't work John Galt Linux - General 32 08-20-2003 01:44 AM

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

All times are GMT -5. The time now is 08:17 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
Open Source Consulting | Domain Registration