Linux - GeneralThis 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
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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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
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.
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
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:
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
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:
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!
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.
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.
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?
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,
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.