LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-04-2012, 04:42 PM   #1
ggalan
Member
 
Registered: Oct 2010
Posts: 57

Rep: Reputation: 0
edit crontab methods


what is the difference between editing your crontab by

Code:
nano crontab
vs
Code:
contab -e
 
Old 01-04-2012, 04:47 PM   #2
PoleStar
Member
 
Registered: Jul 2010
Posts: 165

Rep: Reputation: 2
Code:
nano /etc/crontab
open the basic system crontab, where are the monthly, weekly, daily
crons are.

Code:
crontab -e -u  <user>
open crontab for some user.
 
Old 01-04-2012, 04:56 PM   #3
ggalan
Member
 
Registered: Oct 2010
Posts: 57

Original Poster
Rep: Reputation: 0
but you can setup crons on both?
 
Old 01-04-2012, 05:30 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
man crontab:

Code:
The -e option is used to edit the current crontab using the
editor specified by the VISUAL or EDITOR environment variables.
After you exit from the editor, the modified crontab will be
installed automatically. If neither of the environment variables
is defined, then the default editor /usr/bin/editor is used.
So the -e option simply opens up the current user's crontab file in whatever default editor is set in your shell. Also, while not mentioned above, it checks the syntax before installing the changes, making it safer to use than editing the file raw.

Other than that, yes, you can do it either way.

Last edited by David the H.; 01-04-2012 at 05:31 PM.
 
Old 01-04-2012, 06:49 PM   #5
ggalan
Member
 
Registered: Oct 2010
Posts: 57

Original Poster
Rep: Reputation: 0
i just tried this in both

nano crontab
Code:
* */2 *  *  * echo "hello world! nano"
crontab -e
Code:
* */2 *  *  * echo "hello world! vi"
the vi produced a echo in mail but the nano did not
also when the files are opened in ssh, noticed the opening page was different.
so they must be affecting different files.
 
Old 01-04-2012, 09:07 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
The first will edit a file called crontab, wherever you happen to be ie whichever dir you are in (even if it has to create it) and it will be owned by you.
The cron daemon will know nothing about it, UNLESS it happens to be the /etc/crontab file & you are root (or sudo/su up to root).

The 2nd will edit the default crontab file for your current user, which will be in /var/spool/cron & the cron daemon will be notified about it.

Basically, always use the crontab -e cmd unless you know what you are doing ie editing the crontabs in /etc/ and /etc/cron* dirs and you are root.
 
1 members found this post helpful.
  


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
crontab edit not allowed PMP Linux - Newbie 4 06-03-2009 07:17 AM
crontab -e what does it actually edit? wimnat Linux - General 5 05-26-2009 11:26 PM
Can not edit crontab AbrahamJose Solaris / OpenSolaris 1 02-19-2009 09:31 AM
Can't Edit Crontab rignes Linux - Software 1 04-04-2007 12:01 PM
crontab doesn't let me to edit wedgeworth Linux - Software 10 09-17-2003 01:15 PM


All times are GMT -5. The time now is 08:32 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration