LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-24-2010, 05:22 AM   #1
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: FreeBSD 9.1
Posts: 154

Rep: Reputation: 25
I have deleted crontab by mistake


Hi Guys,

I just made a big mistake. I was accessing my box externally (ssh) and accidentally deleted my crontab. I never used crontab before and issued the command "crontab -d" instead of "crontab -e" to edit and add my cronjob. I am pretty useless because I had no back up of my crontab of course
First question, is there going to be any direct issue on my box because of the crontab being erased ? (I am assuming so but do not know what type of problems..)
Lastly, would I be lucky enough so that there is a way to recover my crontab ? (having gone through Google and whatnote, I doubt it).

Thank you for your help Guys,

Kind Regards,
 
Old 10-24-2010, 05:27 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,528

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
First question, is there going to be any direct issue on my box because of the crontab being erased ?
Well, the cronjob won't be executed any more.
The direct issue will depend on the cronjob you erased.
Quote:
Lastly, would I be lucky enough so that there is a way to recover my crontab ? (having gone through Google and whatnote, I doubt it).
Since you have no backup, I don't think you can recover it.


Kind regards
 
Old 10-24-2010, 05:39 AM   #3
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: FreeBSD 9.1
Posts: 154

Original Poster
Rep: Reputation: 25
repo, thanks for your reply.
the incidence would be that none of the cronjobs that were there would be executed anymore as they are all gone --> OK, but would those cronjobs be similar to all slackware 13.1 install ? If yes, I could just ask someone with a slackware 13.1 install for all the cronjobs and recreate all of them. The point being is that i did not see the type of jobs that were in it so i have no clue the effects of those jobs not being executed.
 
Old 10-24-2010, 05:57 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,528

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Depends, did you erased them as user or as root?
What is the output from
Code:
crontab -l
Take a look at /etc/cron to see the crontabs still installed.
AFAIK crontab -d will only erase the contabs you created, not the system crontabs like cron-daily,cron-weekly...

Kind regards

Last edited by repo; 10-24-2010 at 06:25 AM.
 
Old 10-24-2010, 05:59 AM   #5
maxmiorim
Member
 
Registered: Sep 2010
Location: Brazil
Distribution: Slackware
Posts: 43

Rep: Reputation: 8
Ops, it looks like the coffee didn't kick in yet...

crontab -d will delete the crontab of the user that ran it. Like repo said, the "system" crontabs (i.e. /etc/cron.daily, /etc/cron.weekly and etc.) should be "safe" even if you ran crontab -d as root.

Last edited by maxmiorim; 10-24-2010 at 06:06 AM. Reason: DERP
 
Old 10-24-2010, 11:37 AM   #6
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,719

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
Quote:
Originally Posted by maxmiorim View Post
Ops, it looks like the coffee didn't kick in yet...

crontab -d will delete the crontab of the user that ran it. Like repo said, the "system" crontabs (i.e. /etc/cron.daily, /etc/cron.weekly and etc.) should be "safe" even if you ran crontab -d as root.
Not quite. The root crontab file is what runs the jobs in those directories.
 
1 members found this post helpful.
Old 10-24-2010, 12:15 PM   #7
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,528

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
Originally Posted by Richard Cranium View Post
Not quite. The root crontab file is what runs the jobs in those directories.
You are right.
If the OP did crontab -d as root,
best option is to reinstall dcron.

Kind regards

Last edited by repo; 10-24-2010 at 12:22 PM.
 
Old 10-24-2010, 02:33 PM   #8
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: FreeBSD 9.1
Posts: 154

Original Poster
Rep: Reputation: 25
I did reinstall dcron but to no avail.
The dcron was still installed and I still have no scripts that run cron.daily/weekly/hourly/monthly..
I am in the process of installing a vm and will have look in it to see what can be done in that regards. Worst case scenarios, I will reinstall slack on my box.

Kind Regards,
 
Old 10-24-2010, 03:19 PM   #9
udaman
Member
 
Registered: Oct 2010
Location: New England, USA
Distribution: OpenSUSE/Slackware64/RHEL/Mythbuntu
Posts: 189

Rep: Reputation: 39
Quote:
Originally Posted by riganta View Post
Worst case scenarios, I will reinstall slack on my box.
Don't reinstall the whole OS just cause you deleted a crontab.

If you had a root crontab that had the original entries from an original install, just edit crontab as root and paste this into corntab.

as root do:
Code:
crontab -e
and then paste this code into and save it.

Code:
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this.  If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
That was the crontab from my Slackware 13.1 install that I just did two days ago, and there's no additional edits, so you may have had the exact same thing if you ran 13.1 with no changes.
 
1 members found this post helpful.
Old 10-25-2010, 10:44 AM   #10
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: FreeBSD 9.1
Posts: 154

Original Poster
Rep: Reputation: 25
udaman,

Thanks a lot for your help. The crontab you posted helped a lot. I created a VM and got the exact same content. I recreated all the cron jobs and all his back to normal.

Thanks again guys for all your help. Much appreciated.

Kind Regards,
 
Old 10-25-2010, 01:41 PM   #11
udaman
Member
 
Registered: Oct 2010
Location: New England, USA
Distribution: OpenSUSE/Slackware64/RHEL/Mythbuntu
Posts: 189

Rep: Reputation: 39
riganta,

I'm glad I could be of some help. Cheers!
 
  


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
deleted by mistake .thunderbird valemon Linux - General 6 08-28-2007 05:12 PM
Am i done for? Deleted /etc by mistake AriciU Slackware 10 07-07-2007 06:07 AM
Deleted rc.local by mistake Fredstar *BSD 4 06-18-2007 08:44 AM
Deleted Trash Icon By Mistake, What Now? zhuangshi SUSE / openSUSE 4 03-26-2005 08:58 AM
help pls! deleted something by mistake marlor Slackware 2 02-05-2005 08:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:51 PM.

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