LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-21-2014, 07:05 AM   #1
Geminias
Member
 
Registered: Sep 2005
Posts: 201

Rep: Reputation: 30
I accidentally ran crontab -r


Hi guys, I just ran crontab -r thinking it would let me select the cron task to delete, but instead it seems to have deleted all the cron jobs. These jobs were manually installed (not the system defaults). Is there anyway to recover the previous crontab?
 
Old 07-21-2014, 07:17 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Any backup?
You could try to look in the logfiles to see the excecuted crons in the past.

Kind regards
 
1 members found this post helpful.
Old 07-21-2014, 07:28 AM   #3
Geminias
Member
 
Registered: Sep 2005
Posts: 201

Original Poster
Rep: Reputation: 30
Oh thank god, whoever originally setup the cronjobs was a genius! He made a cron job that copied the crontab into a backup. This is so brilliant because if you accidentally delete the crontab, then the job will no longer run, and the latest crontab will be preserved
 
Old 07-21-2014, 09:55 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Geminias View Post
Oh thank god, whoever originally setup the cronjobs was a genius! He made a cron job that copied the crontab into a backup. This is so brilliant because if you accidentally delete the crontab, then the job will no longer run, and the latest crontab will be preserved
Glad your problem was resolved, but you do realize that you've just hinted at a MUCH larger issue, right???

If you've only got one script, backing up one aspect of your system, you are just WAITING for something bad to happen at this point. Make sure you have working, verifiable backups taking place. If you're the new administrator, start off right.
 
1 members found this post helpful.
Old 07-21-2014, 10:10 AM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
FWIW - all crontabs are stored in /var/spool/cron/. If you make a regular backup of that directory you'll be covered in cases like this.
 
1 members found this post helpful.
  


Reply

Tags
crontab



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem with crontab:: command not executed properly via crontab Ankush Seth Linux - Newbie 11 11-11-2013 06:25 AM
DIff B/w Crontab -l & crontab -e Tareq9959 Linux - Newbie 2 05-14-2013 08:27 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
Accidentally deleting crontab for root yuchai Slackware 3 08-08-2008 01:28 PM
help: accidentally overwrote on crontab auden Slackware 1 02-14-2005 06:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:07 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