LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 08-26-2013, 01:51 AM   #1
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Rep: Reputation: 1
HOWTO backup CRONTAB file in Solaris before editing.


Hi Guys,

Do we really can backup crontab file before eding it ?

If yes, where and which file in Solaris do we need to backup .

Please guide.
I checked Google but not so proper answers.

Thanks.
 
Old 08-26-2013, 02:33 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,085

Rep: Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957
in ubuntu and debian /var/spool/cron/crontabs
otherwise see man crontab (at the end)
probably you will need to reinstall crontab entries instead of just save and restore these files...
 
1 members found this post helpful.
Old 08-27-2013, 08:39 AM   #3
sras
Member
 
Registered: Jul 2013
Posts: 31

Rep: Reputation: Disabled
pan64's answer is exact. Another way would be just redirect the crontab entries to another file before you do any modification..

Code:
crontab -l > /home/user/crons.backup
 
1 members found this post helpful.
Old 08-27-2013, 08:43 AM   #4
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by sras View Post
pan64's answer is exact. Another way would be just redirect the crontab entries to another file before you do any modification..

Code:
crontab -l > /home/user/crons.backup
ohh!! This looks simple!

But then how to revert them?????

Thanks a lot!!!
 
Old 08-27-2013, 08:56 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,085

Rep: Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957Reputation: 4957
crontab -l will print only the crontab of the current user.
The user himself can restore his own crontab using crontab -e and reload that backup
 
1 members found this post helpful.
Old 08-27-2013, 09:31 AM   #6
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
Please can you tell me with an example suppose I have backup done like this

crontab -l > crontab.27Aug2013

,so how to restore this?

Thanks!!
 
Old 08-27-2013, 11:00 AM   #7
sras
Member
 
Registered: Jul 2013
Posts: 31

Rep: Reputation: Disabled
Just edit the crontab (crontab -e) and delete all the entries over there and paste the content from backup file.
 
Old 08-27-2013, 01:22 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,402

Rep: Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548
To upload crontab.27Aug2013 to the current users crontab

crontab crontab.27Aug2013

(I believe it also works this way in Solaris.)

Last edited by michaelk; 08-27-2013 at 01:30 PM.
 
1 members found this post helpful.
Old 08-27-2013, 02:08 PM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,781

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
It works indeed the same way on Solaris. Just make sure the EDITOR variable is set to something your are familiar with before running "crontab -e", eg:

Code:
EDITOR=vi
export EDITOR
crontab -e
Otherwise, you'll be likely very perplexed by the result unless you are familiar with "ed" which is quite unlikely.
 
2 members found this post helpful.
Old 08-28-2013, 01:36 AM   #10
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by jlliagre View Post
It works indeed the same way on Solaris. Just make sure the EDITOR variable is set to something your are familiar with before running "crontab -e", eg:

Code:
EDITOR=vi
export EDITOR
crontab -e
Otherwise, you'll be likely very perplexed by the result unless you are familiar with "ed" which is quite unlikely.
Yes! sometimes sometimes before editing crontab I do run something like EXPORT=VI editor, stuff like that.!
 
Old 08-28-2013, 02:40 AM   #11
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,781

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
"EXPORT=VI" doesn't make sense, that would be
Code:
export EDITOR=vi
 
2 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
Howto stop squid before executing crontab file? gardenair Linux - Server 6 03-15-2011 02:42 AM
Crontab not editing in solaris 8. crown_bd Solaris / OpenSolaris 6 09-06-2007 01:23 AM
editing crontab djgerbavore Slackware 12 05-30-2005 09:24 PM
Howto disable backup file cration VertX Linux - Newbie 1 02-05-2005 05:56 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 08:44 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
Open Source Consulting | Domain Registration