I'm running a Debian server on EC2, and a few days ago my crontab definitions suddenly disappeared. Just vanished without provocation!

Any ideas what can be responsible for that? I don't suspect any unauthorized access to the server.

  • Which particular crontab are you referring to? – Dennis Williamson Feb 14 '11 at 15:18
  • the one I get to edit when typing crontab -e – mba_fv Feb 19 '11 at 13:35
  • I think what Dennis is asking is which users crontab. If you are typing crontab -e as root then that's root's cron. – egorgry Feb 19 '11 at 14:58
  • @Dennis @egorgry: root's. – mba_fv Feb 19 '11 at 15:11
  • Take a look at gtirloni's suggestion and see if the cron even exist and what it the creation time. – egorgry Feb 19 '11 at 15:32

Unfortunately, it's extremely easy to lose a user crontab (and almost as easy when that user is root).

Here are a couple of examples of ways to empty one out:

crontab ''

echo $emptyvar | crontab -

crontab emptyfile

crontab -l | oops | crontab -

Where oops represents some command that is supposed to manipulate the contents output by crontab -l before replacing them using crontab. For some reason ("oops") the contents don't get passed through the pipe.

You should check your scripts and crontabs for any lines that attempt to manipulate root's crontab and make sure they're not doing something wrong.

Also, for user crontabs, when you edit one yourself always use crontab -e.

  • 3
    Also crontab -r will remove it completely. That r is very close to the e too. I've had that awful moment once before on production. Not sure if debian warns you but HPUX doesn't. – egorgry Feb 19 '11 at 15:37
  • @egorgry: I omitted that information since the OP said the definitions disappeared rather than the file. Perhaps I should have included it. – Dennis Williamson Feb 19 '11 at 15:39
  • The crontab -r was my reason. Looking thru the history for the shell had that row.... – Kristoffer Aug 6 '13 at 19:27

It could be that the partition where /var is located was full.

If this is happening and /tmp is located in another partition you can edit the temporal file with crontab -e but when you finish the edition the new version can not be copied to /var/spool/cron/ and as result you obtain an empty file.

I know this is a strange case but crontab does not return any error.


Reading about EC2 issues on forums.aws.amazon.com. Not specifically this problem but static data disappearing after reboots. You might want to jump in to some discussions over there or contact aws support. In the mean time I'd script something to backup my crontabs to S3 or something.


See if the crontab file actually exists in /var/spool/cron/crontab/ before you try to edit it. Is it empty or is it being created at that moment?

Has your EC2 instance rebooted?

grep -r crontab /etc/* and see if there's anything touching them.

  • the file in /var/spool/cron/crontabs/ is non-empty now, after I recreated it. It doesn't repeatedly disappear. And yes, the instance rebooted some time before the disappearance - but why would a reboot wipe out my crontab? – mba_fv Feb 19 '11 at 15:16
  • @mba_fv: Yes, a reboot may have erased your crontab, depending on your EC2 storage settings: "..if you stop or terminate the instance, the data in the instance store will be lost.", cf. the second paragraph in the chapter about storage concepts in the docs. – Axel Knauf Feb 20 '11 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.