LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-17-2018, 11:42 PM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,953

Rep: Reputation: 270Reputation: 270Reputation: 270
crontab -e no longer changes /var/spool/cron/crontabs/root


Edits to root's crontab no longer stick. I get no error when I try. A backup version appears in /run/cron (e.g. /run/cron/crontab.lkfqef~). I can edit /var/spool/cron/crontabs/root then restart crond to the same effect, so it's not a problem. I'm just curious as to why it happens.

I can edit other users' crontab files. The same happens with vi, vim, and emacs. I hadn't revised it in years so don't know when this started.
 
Old 09-18-2018, 01:07 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,708

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
Editing root's crontab:
Code:
su -
(password)
crontab -e
will open in EDITOR (usually vi)
modify and save
 
Old 09-18-2018, 07:29 AM   #3
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,953

Original Poster
Rep: Reputation: 270Reputation: 270Reputation: 270
Quote:
Originally Posted by scasey View Post
Editing root's crontab...
Code:
crontab -e
edits the user's crontab. To edit a different user's crontab requires the
Code:
-u
switch. Thus my message witnessed that I was running as root when I tried. If I try to edit root's crontab when I'm running as RandomTroll, crontab returns an error.

That I reported the same result with different editors witnessed that I had set the environment variable crontab reads to decide which editor to use. On my system, that's VISUAL, by the way.
 
Old 09-18-2018, 09:57 AM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,708

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
Yes, VISUAL. My bad.
I wouldn't expect a non-privileged user to be able to edit root's crontab.
 
Old 09-18-2018, 11:38 AM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
sudo crontab -e -u <user>
is what I use.
 
Old 09-18-2018, 02:22 PM   #6
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,953

Original Poster
Rep: Reputation: 270Reputation: 270Reputation: 270
Quote:
Originally Posted by Habitual View Post
Code:
sudo crontab -e -u <user>
is what I use.
Which makes no difference when I'm already running as root when I run
Code:
crontab -e
. I've been using Linux for 21 years, editing root's crontab files with crontab -e all the time, until recently on my home system it has always worked. There's some kind of protection going on.
 
Old 09-18-2018, 02:54 PM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,708

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
What are the permissions of /var/spool/cron/crontabs/root ?
(Note: on my CentOS server, it's /var/spool/cron/root)
 
Old 09-20-2018, 12:43 PM   #8
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,953

Original Poster
Rep: Reputation: 270Reputation: 270Reputation: 270
I made a mistake in my original message: vi works, vim & emacs don't. vim & emacs create backup files; vi doesn't - don't know why that matters. The backup files remain in /run/cron. Switching to vi is no problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Stablehost vulnerability discovered in /var/spool/cron/crontabs/root file teopro Linux - Security 4 10-23-2014 08:44 AM
Where are cron jobs located when not under /var/spool/cron/root? NotionCommotion Linux - Newbie 6 09-07-2012 07:33 AM
/etc/crontab vs /etc/cron.d vs /var/spool/cron/crontabs/ drManhattan Linux - Newbie 9 01-04-2011 01:12 AM
nothing in /usr/spool/cron/crontabs Furlinastis Slackware 5 06-04-2005 10:16 PM
Failed to lock file /var/spool/cron/root after 5 minutes teeno Linux - Software 0 09-24-2003 02:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration