LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-31-2013, 08:42 AM   #1
derekcripps
LQ Newbie
 
Registered: Dec 2013
Posts: 4

Rep: Reputation: Disabled
Crontab entries deleted, how do I restore?


Not sure what I did, but my backup didn't run last night. When I checked crontab yesterday, it contained the backup entries, today the file is blank. I did a "ls crontab -l" and it shows:

-rw-r--r-- root root 255 Sep 18 04:46 crontab

So I am confused as it appears that the file is here, and has data, but I could be interpreting the information incorrectly.

How do I restore the information into crontab so that my backups will run again? I have a backup of the entire system, that was saved using: "cpio -ocvB > /dev/st0

Thank you in advance for your help.

Derek
 
Old 12-31-2013, 10:40 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Maybe I'm missing the obvious here but how about restoring from a backup made on or before September 18th?
 
Old 12-31-2013, 10:42 AM   #3
derekcripps
LQ Newbie
 
Registered: Dec 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
The backup was made a couple of nights ago, Sept 18th is the date on the crontab file. Is this the last date it was modified?
 
Old 12-31-2013, 10:52 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Yes. If unsure about change, access or modification times use 'stat' on the file.
 
Old 12-31-2013, 10:56 AM   #5
derekcripps
LQ Newbie
 
Registered: Dec 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for the STAT command!

OK, I'm confused then. The crontab file has not been modified since September and is 255 bytes. Why does "crontab -e" now show up empty?

Thanks again,

Derek
 
Old 12-31-2013, 11:08 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
'crontab -e' is for editing the cron spool file of the user account you're logged into. You can find them in /var/spool/cron/. /etc/crontab is edited by hand, preferrably using your visual editor. Also note you can drop cron jobs in /etc/cron.d/, like 'echo "00 * */1 * * root /path/to/script" > /etc/cron.d/doSomething.cron;'.
 
Old 12-31-2013, 11:24 AM   #7
derekcripps
LQ Newbie
 
Registered: Dec 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
OK... so how do I restore the original cron information from tape?

Is this correct:
cpio -ivm /etc/crontab < /dev/st0

If so, what directory do I need to be in to issue the command.

Cheers,

Derek
 
Old 12-31-2013, 03:04 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by derekcripps View Post
Is this correct:
cpio -ivm /etc/crontab < /dev/st0
Yes but add the "-d" switch to have it re-create leading directory names.


Quote:
Originally Posted by derekcripps View Post
If so, what directory do I need to be in to issue the command.
Generally speaking you don't want to overwrite files without first verifying contents so I'd opt for something like /tmp.
 
Old 12-31-2013, 03:38 PM   #9
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,114

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Wait - before you go trying to restore anything, note that your crontab file exists and contains 255 bytes of data. Why don't you try changing to the directory that contains that crontab file and running "cat crontab" to see what's in it? You could also run "od -c crontab" to check out oddball invisible characters that might be present.

If the file were missing or zero length, yes, attempt to restore it. But it is not. So I'd first try to determine what's in it, and after that, determine how it got corrupted (if that's what you find when you look at what's inside).
 
  


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
[SOLVED] Crontab: Cannot see entries, but execution running shivaa Solaris / OpenSolaris 11 02-18-2013 03:38 AM
user cannot edit his cron entries using crontab -e chickenjoy Solaris / OpenSolaris 5 01-19-2010 07:06 PM
Where are the crontab entries stored? abefroman Linux - Server 2 11-15-2006 03:28 PM
Crontab doesn't accept new entries Thakowbbery Linux - Software 5 08-22-2006 02:49 PM
crontab entries will not execute when not logged fatra2 Linux - Software 2 05-23-2006 03:22 AM


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