Operating System - Linux
1753432 Members
4581 Online
108793 Solutions
New Discussion юеВ

Re: Crontab not accepting changes

 
Idris Lirio
Occasional Advisor

Crontab not accepting changes

I have a problem with linux 7.3 crontab -e not writting the changes to the crontab file. Once crontab is opened for root it generates a file in the /tmp directory which is updated when I make changes and :w!, but after I exit with any other option wq, w, etc the tmp file disappears and the changes are not written to cron. There is also a message saying crontab: no changes made to crontab. any help with this is greatly appreciated.
15 REPLIES 15
Fredrik.eriksson
Valued Contributor

Re: Crontab not accepting changes

There could be a permission error?
I'm not sure where the "crontab -e" file is supposed to be stored.
But you could just aswell use /etc/crontab or a local crontab file which you can execute by running:
# crontab /path/to/local/crontab.file

Hope this helps you :)
Best regards
Fredrik Eriksson
Ivan Ferreira
Honored Contributor

Re: Crontab not accepting changes

Try removing and reinstalling your cron:

crontab -l > cron.root
crontab -r
crontab cron.root

Then try to edit again. This is to ensure that permissions for the cron file are correct.

Also, ensure that the crontab command has the SUID and SGID bit enabled:

# ls -la $(which crontab)
-rwsr-sr-x 1 root root 311288 mar 14 2007 /usr/bin/crontab
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Idris Lirio
Occasional Advisor

Re: Crontab not accepting changes

Ivan

I just tried this and still have the smae issue.

/var/spool/cron/root
-rw------- 1 root root 3.2k Nov 13 12:17 root

-rwsr-xr-x 1 root root 21080 Apr 14 2002 /usr/bin/crontab

The funny thing is I can edit the /var/spool file and crontab -e shows the changes, but a straight edit using crontab -e does not even when :w! is used and states cron was updated, but I suspect the update only refers to the /tmp file and not the actual cron file which is never updated on exit
Ivan Ferreira
Honored Contributor

Re: Crontab not accepting changes

Sometimes, when you have a syntax error in your cron file, for example, a missing value, the changes are not saved.

├В┬┐Can you upload a txt file with all your procedure?
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
skt_skt
Honored Contributor

Re: Crontab not accepting changes

check if your / fs is RW mode; You may not have /tmp as seprate file system now. give a try..
Idris Lirio
Occasional Advisor

Re: Crontab not accepting changes

The file contains the entire crontab for root
Johnson Punniyalingam
Honored Contributor

Re: Crontab not accepting changes

#----------------------
# Monitor load avg on noble boxes
#----------------------
*/5 * * * * /root/monitor/loadavg.pl
#----------------------

above entry in your crontab looks to me wrong.


A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)


Thanks,
Johnson
Problems are common to all, but attitude makes the difference
Dennis Handly
Acclaimed Contributor

Re: Crontab not accepting changes

>Johnson: */5 * * * * /root/monitor/loadavg.pl
>above entry in your crontab looks to me wrong.

You might want to explain what you think is wrong? That "*/5" syntax seems to be linux for every 5 minutes. (Not valid for HP-UX though.)
Idris Lirio
Occasional Advisor

Re: Crontab not accepting changes

I agree the */5 is a valid entry and we use it on our other 7.3 boxes which happen to be red hat. Sorry for not mentioing that earlier