Jump to content

Crontab problems


valkarye

Recommended Posts

Hope someone can help,I'm using RedHat 9 that seems to be working fine, with one exception - I'm unable to install or edit a new crontab, even as root. Following the man page and other tutorials, I've removed the crontab entry (crontab -u root -r) and then created a new file using vim and attempted to install the new crontab using the command: crontab foo.txt . After hitting enter, the system pauses for a few seconds and then returns back to a prompt - with no mention of installing a new crontab. Running crontab -e displays no information and any info that is updated and saved (:wq!) never displays the next time -e is run.ps -ef | grep cron shows that crond is running and /var/log/cron doesn't throw out any glaring errors (that I'm aware of).Any ideas?Thanks,EricP.S. This is system wide for all users

Link to comment
Share on other sites

Hi Eric This is a pretty weird problem indeed :) . . . . I am wondering if you still have the following files: /etc/crontab /etc/cron.hourly, daily, weekly, monthly /etc/anacrontab Also, is there maybe something blocked in /var/spool/cron/XXXX ? You might want to try to upgrade the crontab file, Here is the latest for RH 9 . . and install it with:

# rpm -Uhv crontabs-1.10-5.noarch.rpm

If that does no good maybe try the same with anacron

# rpm -Uhv anacron-2.3-25.i386.rpm

:) Bruno

Link to comment
Share on other sites

linuxdude32

Welcome to the forum, Valkarye!Root not having a crontab might be perfectly normal. I don't have Fedora but my SuSE system doesn't have one either:

linux:~ # crontab -lno crontab for root

I do, however, have cron.d, cron.daily, cron.weekly, cron.monthly directories under /etc, like Bruno talks about. I was able to create my own crontab, which I use for running xsetia@home and it appears here:

linux:~ # crontab -u jason -l# DO NOT EDIT THIS FILE - edit the master and reinstall.# (/tmp/crontab.6635 installed on Thu Apr 29 14:10:25 2004)# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)0 1,5,9,13,17,21 * * * cd setiathome-3.08.i686-pc-linux-gnu; ./setiwithgraphics

If you setup the cronjob you created to output something to a log, you should be able to instantly see if it was loaded or just try displaying it like I have above. Let us know what error messages you get when you try this stuff since it helps us to help you.

Link to comment
Share on other sites

Thanks for the responses, here are my replies:BrunoAll cron and anacron components are present in /etcOnly the users I attempted to create crontabs for are listed under /var/spool/cron/XXXUpdating the rpms is a no-go as linux give me the standard "package foo is already installed"linuxdude32Crontab runs as root on 2 other Redhat 9 boxes that I test on. The problem with this box is that it is a production web and MySQL server and I'm trying to manage the backups better than manually running the backup scripts. This also explains why I'm hesitant to remove crontabs and anacron and reinstall (nothing ever goes smoothly for me).When I do crontab -l , I get no response - just a return. No mention of a crontab being present, even after I attempt to edit (via crontab -e).I am very confused.

Link to comment
Share on other sites

linuxdude32

Not sure what's going on there. :blink: To re-install an RPM you already have you can force it:# rpm -Uvh --force foo.rpm

Link to comment
Share on other sites

Just did the --force, but the result is still the same. All the logs look good: nothing bad in the spool, and /var/log/cron sure makes it look like everything is running properly.Any other place where an error might be logged?

Link to comment
Share on other sites

linuxdude32
Following the man page and other tutorials, I've removed the crontab entry (crontab -u root -r) and then created a new file using vim and attempted to install the new crontab using the command: crontab foo.txt .
Just noticed this after looking again. You created a new crontab using vim? Me thinks you have to run crontab -e right from the start, but maybe I'm off. You could try doing it that way since there doesn't seem to be anything there. Btw if you're doing backups, did you try just putting the script into /etc/cron.daily or which ever directory makes sense? Also, did you check root mail? Oftentime errors from cronjobs are sent to root unless directed not to.
Link to comment
Share on other sites

linuxdude32crontab done by starting with a file or by -e produces the same null result. Actually when you go the -e route, linux tells you that changes are made, but it's not the case.root or no other user has any mailbrunoThis is the way I have setup cron. Interestingly enough the entries in /var/spool/username are 0 byte files, in which the owner has rw privileges.OK, this looks like it might go somewhere.Investigating...

Link to comment
Share on other sites

Hi EricJust for a test . . . . use the Tip I linked you to as a test to make a user-cron-job . . . and see if it works . . . My "cat /var/spool/cron/bruno" shows:

[root@jupiter bruno]# cat /var/spool/cron/bruno# DO NOT EDIT THIS FILE - edit the master and reinstall.# (Test_Cron installed on Sat Apr 17 21:21:28 2004)# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)0 * * * * play /home/bruno/Sounds/Hour.wav30 * * * * play /home/bruno/Sounds/HalfHour.wav

The file I used to make it looks like this:

0 * * * * play /home/bruno/Sounds/Hour.wav30 * * * * play /home/bruno/Sounds/HalfHour.wav

And is called Test_Cron, located in /home/bruno . . . the command I used was

crontab Test_Cron

B) Bruno

Link to comment
Share on other sites

And it finally looks like I've found a problem:When I try to manually modify the /var/spool/cron/root file (which sits at zero bytes) I receive a "write error in swap file" error when the file opens. Then when I manually put in scheduling info and attempt to save, I get a "write error (file system full)" error and am unable to save the file.df -h shows I have plenty of disk space so I think I've got a corrupt file system.Sound right? Comments?

Link to comment
Share on other sites

Right Eric we are there !! . . we found the culprit . . :DYou can not manually edit the /var/spool/cron/root file . . it says:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
Now to set things straight could you do:
# ls -al /var/spool/cron

and post the results ?B) Bruno

Link to comment
Share on other sites

Right, I know you're not supposed to edit the /var/spool/cron/*user* file but since my files stay the same zero byte size and never have any contents, I had to try something.I just set up a dummy cronfile on my test box and directly edited the file using vim - looking for write errors. The file modified and saved correctly.I'm now about 95% sure this is a file system issue.

Link to comment
Share on other sites

And there is no hidden swapfile left behind ? . . . . . Check with "ls -al /var/spool/cron" for hidden files that are blocking normal functioning . . B) Bruno

Link to comment
Share on other sites

No hidden files, just the zero byte files for users (empty of course) and the . and .. files.This server sits in another city and runs headless, so is there anyway to check for filesystem corruption - I dare not reboot since if it is corrupt, I can't fsck from the console.I'm hosed!

Link to comment
Share on other sites

Hi EricYou can only fsck ( filesystemcheck ) on an unmounted drive . . . . so the answer is no . . . . . depending on if it is Ext2 or Ext3 ( journalled ) a reboot is NO or YES safe ;)B) Bruno

Link to comment
Share on other sites

Bruno, linuxdude32Thanks for all your help. I'm in the process of running badblocks on the mounts and it's turning up tons of errors, so it's more than likely a hardware problem. I've seen interactive filesystem fix sceens on ext3 before, so I'm going to wait until I'm sitting in front of the console before I reboot.All of your suggestions and comments were greatly appreciated. Needless to say, I've learned quite about cron - at least the way it should work!

Link to comment
Share on other sites

nlinecomputers
Sorry nlinecomputers, didn't mean to leave you out!
Thanks you didn't I was mostly lurking on this topic. Burno and Linuxdude were asking the same questions I would have asked but they beat me too it. I hope you have backups.... ;) :D ;) :D
Link to comment
Share on other sites

linuxdude32

Glad you figured it out, Eric. Hope your drive isn't going or that you have enough time to get the stuff of it first. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...