Operating System - HP-UX
1752796 Members
5824 Online
108789 Solutions
New Discussion юеВ

Re: crontab removed by mistake (crontab -r instead of crontab -e)

 
SOLVED
Go to solution
Ravi S. Banda
Regular Advisor

crontab removed by mistake (crontab -r instead of crontab -e)

crontab removed by mistake (crontab -r instead of crontab -e):
Since the letters "e" and "r" are next to each other, I mistyped "r" instead of "e" and it removed my crontab file. Is there anyway I can restore the removed the crontab file, please!?!?

Thanks!
Ravi.
3 REPLIES 3
Stuart Abramson
Trusted Contributor

Re: crontab removed by mistake (crontab -r instead of crontab -e)

You're in trouble. Get it from backup tape or from another system.

I always use a sequence like this:

crontab -l > cron.old
cp cron.old cron.new
vi cron.new
crontab < cron.new

Never, never, change anything without making a backup copy first.
TwoProc
Honored Contributor
Solution

Re: crontab removed by mistake (crontab -r instead of crontab -e)

Restore from tape the following file:
/var/spool/cron/crontabs/[username].

So, if it's root's crontab that your after, restore /var/spool/cron/crontabs/root from your last backup.



We are the people our parents warned us about --Jimmy Buffett
Bill Hassell
Honored Contributor

Re: crontab removed by mistake (crontab -r instead of crontab -e)

Unfortunately, r and e are right next to each other. That's one of the reasons I never recommend -e. Instead, you start by creating a local copy of your crontab entry as in:

crontab -l > $HOME/crontab.root

Then, you edit the file, and once changes are complete, use:

crontab $HOME/crontab.root

to activate the new crontab list.


Bill Hassell, sysadmin