Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

can't find crontab maybe deleted. Need to find or reconstruct.

Posted on 2013-01-04
6
Medium Priority
?
431 Views
Last Modified: 2013-02-09
Ok. I did "crontab -" then "crontab -l". When I hit the crontab -l nothing was returned. I think I may have deleted with that command or accidentally in the crontab -e. Is it really deleted? If not, how can I find it? If yes, how can I restore it? I did a some research online and found some examples but the grep commandname1 /var/log/cron was giving me the error message "Permission denied." The history doesn't seem to show the scripts that were executed in the last 24 hours. Is there a way to do that so I can recreate it manually?

986      9:51      crontab -1
   987      10:23      crontab -
   988      10:23      crontabl -l
   989      10:23      crontab -u rhuff -1
   990      10:23      ld
   991      10:23      crontab
   992      10:26      crontab -e
   993      10:38      pwd
   994      10:38      cd ..
   995      10:38      ls
   996      10:38      crontab -l
   997      10:40      cat /var/spool/cron/*
   998      10:41      grep commandname1 /var/log/cron
   999      10:42      cd /var/cron
  1001      10:49      history
0
Comment
Question by:libertyforall2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 38746412
When the cron file has been deleted and you have no backup of it, recovery is not possible.

/var/log/cron is giving you access denied: look at the file with "ls -l /var/log/cron" and you'll probably see that it's accessible for root only. So either become root or ask you sysadmin to do the grep command for you.

From the /var/log/cron logfile you should be able to recover the commands that were in your crontab file, the schedule you would have to recreate.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 38746515
as already said, if you aciddently deleted the crontab you can only recover it from your backup

the location of crontab file depend on your *ix flaviour, some common places are
  /var/log/cron/
  /var/spool/cron/
  /var/spool/cron/crontab/
  /var/spool/cron/crontabs/
  /var/spool/crontabs/
  /etc/crontab/
  /etc/crontabs/

in any directory the name of the crontab file for a user is the systems username (in your example probably rhuff)
use find as root to check for crontab files
0
 

Author Comment

by:libertyforall2
ID: 38746596
Problem was there was no backup. That said, is there a way to do a history search of processes automatically initiated within the last 24-48 hours or do some type of modified history search and reconstruct it manually?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 1000 total points
ID: 38746614
Have a look in the suggested log files / locations mentioned. If you know specifics, look in logfiles for applications/scripts that may have been started by cron. Ask an admin for assistance if you need to because you cannot access all logfiles needed as some are protected, as you've seen already.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 1000 total points
ID: 38746621
syslog (or messages again on newer systems) should contain a entry like:
Jan 23 23:23:23 marvin crontab[4711]: (root) BEGIN EDIT (root)
0
 

Author Closing Comment

by:libertyforall2
ID: 38871394
Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question