LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   I have deleted crontab by mistake (https://www.linuxquestions.org/questions/slackware-14/i-have-deleted-crontab-by-mistake-840109/)

riganta 10-24-2010 05:22 AM

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,

repo 10-24-2010 05:27 AM

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

riganta 10-24-2010 05:39 AM

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.

repo 10-24-2010 05:57 AM

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

maxmiorim 10-24-2010 05:59 AM

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.

Richard Cranium 10-24-2010 11:37 AM

Quote:

Originally Posted by maxmiorim (Post 4137512)
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.

repo 10-24-2010 12:15 PM

Quote:

Originally Posted by Richard Cranium (Post 4137739)
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

riganta 10-24-2010 02:33 PM

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,

udaman 10-24-2010 03:19 PM

Quote:

Originally Posted by riganta (Post 4137866)
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.

riganta 10-25-2010 10:44 AM

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,

udaman 10-25-2010 01:41 PM

riganta,

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


All times are GMT -5. The time now is 08:12 AM.