Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crontab -r deletes crontab without warning. #26

Open
skorokithakis opened this issue Jul 5, 2024 · 5 comments
Open

crontab -r deletes crontab without warning. #26

skorokithakis opened this issue Jul 5, 2024 · 5 comments

Comments

@skorokithakis
Copy link

Deleting a crontab without any warning at all when a user mistypes the most commonly used command (crontab -e) as the letter next to that is... unwise. Adding a prompt to confirm deletion, or making a backup, would save a few crontabs.

@vixie
Copy link
Owner

vixie commented Jul 5, 2024 via email

@skorokithakis
Copy link
Author

Would it be acceptable to create a backup somewhere, to enable the user to undo the deletion?

What's the use case for deleting a crontab? I've always just cleaned the lines by hand, so I'm not sure how people use -r.

@vixie
Copy link
Owner

vixie commented Jul 5, 2024 via email

@skorokithakis
Copy link
Author

and it would have to be created by the sysadmin not by the crontab command "on
demand". would that solve any problems or simply add more confusion?

Well, given that I've been a Linux user for more than twenty years and I only discovered the -r command today (when it a typo ate my crontab), I'd be very grateful if I even could ask my sysadmin to restore my file.

I agree that crontab is so widely used that it's basically ossified and very few changes are possible, but the footgun of one letter being "edit, the thing you do multiple times a day" and the letter next to it being "say goodbye to your data" means I'll never be comfortable typing crontab -e again. Maybe I should just set an alias that won't let me type crontab -r, or maybe crontab should have a big warning on this, but the current behavior seems a bit problematic.

By the way, which part of POSIX is this behavior defined in? I don't remember offhand any other utility where -r deletes data like this...

@Et7f3
Copy link

Et7f3 commented Oct 3, 2024

we can't break shell scripts that depend on the posix behaviour. suggestions welcomed.

Shell scripts doesn't run in tty most of the time. It can if someone want to test a script. In that case the message could be:
"We detected you are running in an interactive session so you seems to be a human. You are about to delete all cron for users X. To avoid this confirmation question you can do cat | cron" the cat | while open a pipe so not tty.

It is the same heuristics used by git, xxd, grep, ... when choosing to emit colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants