FS#18352 - [dcron] crontab -e doesn't save changes
Attached to Project:
Arch Linux
Opened by Jackson (toomanymirrors) - Monday, 15 February 2010, 20:40 GMT
Last edited by Andrea Scarpino (BaSh) - Sunday, 29 May 2011, 23:07 GMT
Opened by Jackson (toomanymirrors) - Monday, 15 February 2010, 20:40 GMT
Last edited by Andrea Scarpino (BaSh) - Sunday, 29 May 2011, 23:07 GMT
|
Details
Description:
Crontab.daily scripts are being run at 10am I would like them to be run much earlier in the morning. Using crontab -e as root or using sudo I try and change the file to remove the @daily and add a line: * 2-5 * * * FREQ=1d/10m ID=sys-daily /usr/sbin/run-cron /etc/cron.daily as soon as I save and exit I can run crontab -e again and the changes are not reflected. Additional info: * package version(s) dcron 4.4-1 * config and/or log files etc. Steps to reproduce: crontab -e make changes :wq crontab -e |
This task depends upon
Closed by Andrea Scarpino (BaSh)
Sunday, 29 May 2011, 23:07 GMT
Reason for closing: Fixed
Additional comments about closing: dcron 4.5-1
Sunday, 29 May 2011, 23:07 GMT
Reason for closing: Fixed
Additional comments about closing: dcron 4.5-1
I can't reproduce it too. It works for me with vim and without setted $EDITOR.
@toomanymirrors: Can you tell us the output of
ls -la /var/spool/cron/
and of
ls -la /var/spool/cronstamps/
total 12
drwxr-xr-x 2 root root 4096 Feb 15 15:40 .
drwxr-xr-x 9 root root 4096 Feb 15 10:17 ..
-rw------- 1 root jalley 0 Feb 14 15:09 jalley
-rw------- 1 root root 513 Feb 15 15:39 root
ls -la /var/spool/cronstamps/
total 24
drwxr-xr-x 2 root root 4096 Jan 26 09:30 .
drwxr-xr-x 9 root root 4096 Feb 15 10:17 ..
-rw-r--r-- 1 root root 16 Feb 15 10:42 root.sys-daily
-rw-r--r-- 1 root root 16 Feb 15 19:41 root.sys-hourly
-rw-r--r-- 1 root root 16 Feb 13 15:30 root.sys-monthly
-rw-r--r-- 1 root root 16 Feb 9 17:54 root.sys-weekly
EDIT: I'm confused by what you mean by Fixed. Is there a patched version of crontab to deal with backup files or does everyone who uses vim have to disable backup files?
Stuff in /etc/cron.* get's executed just fine, and the prick is in DAEMONS. Now, there's no cron or crontab group in the system but if it doesn't even work for root, guess this is not the source of the problem.
EDIT: yes it did have to do with the editor, but it was not 100% the editor's fault =/
Many editors, particularly vim, make a form of backup (known in vim as 'writebackup') when writing, in case the write goes wrong (bad disk, hardware failure, power outage, etc), then at least the original file can be recovered. To do this, it moves the original file foo to foo~, and then saves the new version as foo. Because crontab keeps the same handle open, it's handle is still pointing to foo~, not foo. Thus, crontab sees no changes.
Personally I consider this to be a bug in crontab. Don't use file handles this way. Sure it might be slower to do it differently, but crontabs are small and don't change often.
In the meantime, there are 4 ways to fix this problem, at least in vim. Add one of the following to your .vimrc:
1. Disable writebackups completely:
set nowritebackup
2. Disable writebackups for crontab files only:
au BufEnter crontab.* setl nowritebackup ## This doesn't work for me, I don't know why ##
3. Set writebackup to copy instead of move, for all files:
set backupcopy=yes ##### SLOW, NOT RECOMMENDED #####
4. Set writebackup to copy instead of move for crontab files only:
au BufEnter crontab.* setl backupcopy=yes
I recommend option 4, though I still maintain that this is a bug in crontab. Other editors may have this problem, consult the documentation or support channels for your editor to find a similar fix.