SlackwareThis Forum is for the discussion of Slackware Linux.
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.
1) I have EDITOR and VISUAL set in my own and root's ~/.profile to emacs. This does not allow me to change crontab, either in X or at the console. I need to "export EDITOR=vim" in order to change cron settings. Why is this?
2) One of the examples in the crontab(1) man page is as follows:
Quote:
To request the last Monday, etc. in a month, ask for the "5th" one. This will always match the last Monday, etc., even if there are only four Mondays in the month:
Code:
# run at 11 am on the first and last Mon, Tue, Wed of each month
0 11 1,5 * mon-wed date
When the fourth Monday in a month is the last, it will match against both the "4th" and the "5th" (it will only run once if both are specified).
Does this sample cron entry not cause the date command to run on the first and fifth day of the month (as long as those days fall in the range Mon-Wed), instead of the first and fifth Monday of the month? I'm not long awake so perhaps I'm missing the obvious!
1) If EDITOR is not exported, then it won't be in the environment of the "crontab -e" process. The X environment inheritance is a little hit&miss and will amongst other things depend on how its started. I've added an /etc/xprofile to my system to make things a little more reliable.
2) From just above the examples in the man-page:
Quote:
If you specify both a day in the month and a day of week, it will be interpreted as the Nth such day in the month.
Seems counter intuitive to me (I would have expected it to do the same as what you were expecting), but that seems to suggest that its the latter.
1) If EDITOR is not exported, then it won't be in the environment of the "crontab -e" process. The X environment inheritance is a little hit&miss and will amongst other things depend on how its started. I've added an /etc/xprofile to my system to make things a little more reliable.
Perhaps I have this wrong, but print $EDITOR does return /usr/bin/emacs.
Perhaps I have this wrong, but print $EDITOR does return /usr/bin/emacs.
Since 'crontab' is SUID, I'm guessing it starts a new process (that execs emacs) and thus requires that you 'export EDITOR'.
EDIT: Oops! I failed to read your post properly (it must be all that cough syrup I drank earlier). Well, I tried 'export EDITOR' on my machine and it worked fine.
Since 'crontab' is SUID, I'm guessing it starts a new process (that execs emacs) and thus requires that you 'export EDITOR'.
EDIT: Oops! I failed to read your post properly (it must be all that cough syrup I drank earlier). Well, I tried 'export EDITOR' on my machine and it worked fine.
Did you try to change a setting? I should have mentioned that it opens fine in emacs and I can seemingly make changes and write those changes to disk but when I reopen the crontab it has reverted to the default settings.
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Rep:
Nope...
The 1 is a "well unknown" feature... I stuck on this many times as a emacs user...
Same for SUDO I think...
I go through nano (sorry I don't know enough VI to be vim at ease)
Problem is the cron edition use a "jailed" version of the file, which have a "static" uid (inode?) anyway, when you save with emacs this effectivelly "duplicate" the file and replace it... So the "hard linked" link to the edited file remains untouched... And when you leave the "cron edition process" doesn't see a change so your changes are simply lost...
Use an editor that saves files 'inplace' (the real physical file) not juggling with copies, renaming, backups...
I don't know if we can force emacs to act like this. But nano does (vim does too ).
So:
Code:
$ EDITOR=nano crontab -e
Should do too.
OR... like you did:
Code:
$ EDITOR=vim crontab -e
So in short: it's an emacs behavior... Not a problem with environment variable or anything.
Cheers.
Last edited by NoStressHQ; 11-13-2014 at 06:42 PM.
Problem is the cron edition use a "jailed" version of the file, which have a "static" uid (inode?) anyway, when you save with emacs this effectively "duplicate" the file and replace it... So the "hard linked" link to the edited file remains untouched... And when you leave the "cron edition process" doesn't see a change so your changes are simply lost...
Great explanation. Thanks for that. It works fine in NetBSD by the way. In Slackware I can just about get by with vim for occasional crontab editing if I have to!
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Rep:
Quote:
Originally Posted by gezley
It works fine in NetBSD by the way
Well, if I "see well" the problem, I didn't dig into the code to see why and if we can blame anybody, I don't care, once I understood, the workaround was faster that trying to fix it.
I'd suspect that was somehow the emacs way of doing things, but it can be coupled with which kind of file system do the job and how the 'driver' handles it... Also one who can be "blamed" is the 'crontab -e' (or sudoers editor) which keep a hard link to the file during the "external edition process" instead of reloading it from name after edition is done, which, I think would have been more "robust", and simpler for everybody...
Cheers
Garry.
PS/ Haha I always "C-x C-s" before submitting those messages...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.