LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-29-2002, 06:03 PM   #1
John Galt
LQ Newbie
 
Registered: Dec 2002
Distribution: Mandrake 8.1
Posts: 17

Rep: Reputation: 0
crontab won't work


I am having a problem with crontab..mainly that it won't work. I've played with it for over an hour and still can't get it to run anything at all. Currently I have a test file called "test". All that is inside of it is

* * * * * xclock
[blank line]

I would like to use crontab but I couldn't even get this test file to run. As u can see its set to run every minute and launch xclock. I have tried other applications and also tried using applications from their own dir such ass

* * * * * /usr/X11R6/bin/xclock
[blank line]

I have tried changing the asterisks to numbers coresponding to the current time such as.

30 * * * * /xclock
[blank line]

Trying something like this on the 29th minute of the hour. Still to no avail. I have multiple test files now..As far as I know the only syntax involved in loading the file into the crontab database is

crontab "filename"

This command seems to do something so I assume that is not the problem but after playing with it for so long. I can't figure out what the problem is. Anyone got any ideas?
 
Old 12-29-2002, 06:53 PM   #2
pjcp64
Member
 
Registered: Dec 2002
Location: Omaha, NE
Distribution: Ubuntu Server and SuSE
Posts: 69

Rep: Reputation: 15
Have you verified that crond is running? ps -ef | grep cron

You might also want to look at the cron log. /var/log/cron
This should give you an insight into the problem.

Were you editting the crontab with a crontab -e

I'd also consider trying something even less complex than xclock.
/bin/date >> /date.log for instance.

Hopefully this will work. If it does, then the problem with your xclock job is probably that you need to specify the entire path. Try "which xclock"
 
Old 12-29-2002, 07:44 PM   #3
John Galt
LQ Newbie
 
Registered: Dec 2002
Distribution: Mandrake 8.1
Posts: 17

Original Poster
Rep: Reputation: 0
yes I've verified crond is running.

I checked the cron log and the error and warnings files were both empty

I was editing the crontab w/ emacs. crontab -e opens up vim and I hate vim

I just tried /bin/date >> /date.log

Still won't work. Also I have tried the entire path when trying xclock. Also the /bind/date >> /date.log already has the entire path so I don't think that is the issue. As far as I can see with everything I've read about crontab now online I should be a freaking crontab expert..yet I can't get it to work still. Thanks for the reply though
 
Old 12-29-2002, 08:27 PM   #4
pjcp64
Member
 
Registered: Dec 2002
Location: Omaha, NE
Distribution: Ubuntu Server and SuSE
Posts: 69

Rep: Reputation: 15
Crontab Issue

Try the following:

crontab -l ( this lists the entries in crontab, I bet it's blank. )
crontab -e ( to add the entry you'd like )

The "-e" option is used to edit the current crontab using the editor
specified by the VISUAL or EDITOR environment variables. After you
exit from the editor, the modified crontab will be installed automatically.

I've gotten used to vi and vim, but you could change the environment variables to use emacs if you like.
As you can see, the crontab -e does more than just modify the file.

I'm assuming you're doing this as root. If not, verify that you either don't
have any /etc/cron.allow and /etc/cron.deny files. If you do have these files,
validate their values.
 
Old 12-29-2002, 08:39 PM   #5
John Galt
LQ Newbie
 
Registered: Dec 2002
Distribution: Mandrake 8.1
Posts: 17

Original Poster
Rep: Reputation: 0
aha...I found a new site the had a little more info and fixed the initial problem I was having. kinda stupid on my part but I didn't know how it worked. Turns out when crond starts up it loads all the crontab files into memory..then tries to execute them. Well when crontab started (4 days ago) I had no crontab files at the time. So none were loaded into memory. Hence restarting crond it now tries to run my crontab every minute. Onto the new problem.

"sendmail: fatal: my hostname localhost is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf"

That is the exact error I get. My problem is I could give a crap about using "mailto" in my crontabs. I don't know why it is so adamante upon this setting. I don't want to set myhostname or mydomain. Is there any generic setting I can add that will disable this feature or at the very least..keep things local. I have no interest in mailing anything to anyone w/ crontab
 
Old 12-29-2002, 09:02 PM   #6
pjcp64
Member
 
Registered: Dec 2002
Location: Omaha, NE
Distribution: Ubuntu Server and SuSE
Posts: 69

Rep: Reputation: 15
Bingo

That's good news. I believe crontab -e will update the settings in memory without having to actually cycle the cron daemon itself.

As far as why your cron is trying to email, try:

[root@rh01 etc]# ll -d /etc/cron*
drwxr-xr-x 2 root root 4096 Oct 27 12:08 cron.d
drwxr-xr-x 2 root root 4096 Oct 30 22:02 cron.daily
drwxr-xr-x 2 root root 4096 Oct 27 12:06 cron.hourly
drwxr-xr-x 2 root root 4096 Oct 27 11:50 cron.monthly
-rwxr-xr-x 1 root root 309 Oct 27 12:07 crontab
drwxr-xr-x 2 root root 4096 Oct 27 11:50 cron.weekly

These files have entries in them, and I bet one of them is trying to email using
/etc/postfix. If the job that uses it needs to run, try adding a 2> /dev/null to the end of its cron entry. This'll reroute any errors to the bit bucket.

My hostname is just RH01 without a domain or anything. My /etc/postfix/main.cf has the following line:

mydestination = $myhostname, localhost.$mydomain
 
Old 12-30-2002, 02:54 AM   #7
John Galt
LQ Newbie
 
Registered: Dec 2002
Distribution: Mandrake 8.1
Posts: 17

Original Poster
Rep: Reputation: 0
Well I think thats definately the right track..after checking all the above folders I found a total of 4 references to postfix. 3 of them were simply scripts (all identical)to check postfix for errors which would seem to be what I'm getting. I'm going to have to grep the contents of every file on the drive to find any more of those scripts to "check" postfix and disable them. Annoying but hell i'll let it run and go to bed :-). If you can think of the locations before then that would be hella helpful. But you've already been very helpful. Thanks for the great reply
 
Old 12-30-2002, 04:01 AM   #8
NGraphiX
Member
 
Registered: Feb 2002
Location: Jerusalem, Israel
Distribution: Fedora Core 3
Posts: 154

Rep: Reputation: 30
A Ayn Rand fan in the GNU world .. cheers!
 
Old 12-30-2002, 10:49 AM   #9
John Galt
LQ Newbie
 
Registered: Dec 2002
Distribution: Mandrake 8.1
Posts: 17

Original Poster
Rep: Reputation: 0
;-)
 
Old 12-30-2002, 08:31 PM   #10
pjcp64
Member
 
Registered: Dec 2002
Location: Omaha, NE
Distribution: Ubuntu Server and SuSE
Posts: 69

Rep: Reputation: 15
That's good news John...

I don't quite follow why you'd need to check the entire drive though. The cron jobs are probably the only ones that run this regularly. After disabling the postfix cron jobs, any errors you get would be the result of something you're currently running.

But anyway, it'll be a good exercise in recursive grepping. I'd recommend a process something like this:

find / -type f | xargs file | grep text$ | cut -f1 -d":" | xargs grep postfix * > ~/regrep.out &

The only problem is that the final output doesn't show you the entire path to the filename itself. You could create a list with:
find / -type f | xargs file | grep text$ | cut -f1 -d":" > ~/file.list.out &
but then you'd have to cross-reference. I'm sure there must be a better way!

Have fun!

Thom
 
Old 12-31-2002, 01:18 AM   #11
John Galt
LQ Newbie
 
Registered: Dec 2002
Distribution: Mandrake 8.1
Posts: 17

Original Poster
Rep: Reputation: 0
ummm.....yeeeaaaaaaaaaaa...i'm more confused now than ever. Lets begin the tale of some really weird events in "The history of linux according to John" (John isn't my real name btw as Ngraphix mentioned). So while I'm playing with all this wonderful stuff today I happen to by chance print the date.log file. For the last 24 hours my test crontab gave the instruction that you recommended before "/bin/date >> date.log". Well what do you know it had the date/time of every minute for the last 24 hours. It was working. So I'm like ok. No more errors either. So I changed the test file to run xclock. Didn't work. Then I remembered I had to rerun the crond daemon. So I did that now I'm back to the postfix errors again. Whats even more strange is that even though "/bin/date >> date.log" is not mentioned anywhere anymore it is still piping date into the date.log file every minute even after changing the crontab and restarting crond. my crontab-l now reads

* * * * * xclock
[blank line]

I'm so hella confused now I have no clue where to go from here. You have been so helpful I figured maybe u could figure this doozy out.

BTW my real name is Shane ;-)
 
Old 12-31-2002, 06:10 AM   #12
pjcp64
Member
 
Registered: Dec 2002
Location: Omaha, NE
Distribution: Ubuntu Server and SuSE
Posts: 69

Rep: Reputation: 15
Shane,

Maybe we can figure this thing out over the phone... I'll send you an email with my number. You could call either this evening ( 6-8 CST ) or tomorrow during the day.

Thom
 
Old 12-31-2002, 09:16 PM   #13
pjcp64
Member
 
Registered: Dec 2002
Location: Omaha, NE
Distribution: Ubuntu Server and SuSE
Posts: 69

Rep: Reputation: 15
John,

If I were you i'd:
1) blank out your date.log file.
2) I'm assuming the postfix error check in the cron directories haven't reappeared.
3) crontab -e to modifiy your crontab back to * * * * * /bin/date >> date.log
( I know you hate vim...... but the "-e" is important and it's only 31 letters altogether )

I bet this fixes it. I'm guessing that xclock is erroring for some reason relating to the fact that it doesn't care to run from cron. Because of this its trying to send a postfix email ( to root@localhost ??? ).

If it doesn't fix things, it might be that all of our shanigans have put a wierd setup into memory. Try rebooting to clear all the memory out and see what happens.

xclock might also be erroring out because it can't find the command in the $PATH. It's best to use the full paths in cron.
* * * * * /usr/X11R6/bin/xclock

One question, why do you want to run xclock from cron anyway?

Hope this helps.

Thom
 
Old 02-19-2003, 01:51 PM   #14
broadaxe
LQ Newbie
 
Registered: Feb 2003
Posts: 1

Rep: Reputation: 0
John,
You can change the default editor that crontab uses by setting your VISUAL environment variable. In bash, you may just type, at the prompt,

export VISUAL=emacs

provided emacs is in your default path, this would change the editor for a bunch of stuff, including crontab. You can also include the line above in your .bash_profile to make the change permanent. You might also want to include,

export EDITOR=emacs

while you are at it.

Hope this helps.
 
Old 05-27-2003, 03:30 PM   #15
hershst
LQ Newbie
 
Registered: May 2003
Posts: 10

Rep: Reputation: 0
Unhappy More frustration with cron

I am following up on John's trail.
I also went to crontab -e (both as roor and as Admin)
and typed
* * * * * /bin/date >> /date.log
and -- failure.

No /etc/cron.deny or /etc/cron.allow
Restarted service crond on Red Hat 8
(Also no mention of root or Admin in/etc/crontab,
but they don't have to be there, right?)
Feeling frustrated!
 
  


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 does not work need help Xris718 Linux - General 10 04-18-2004 08:55 PM
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

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

All times are GMT -5. The time now is 03:25 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