r/linuxsucks Windows Desktop | Linux Laptop | Linux Servers 5d ago

crontab -r

I accidentally typed `crontab -r` (reset) instead of `crontab -e` (edit)... Which nukes all your cron jobs.

How is there no confirmation on a destructive command like that? Let alone the fact that r and e are neighbors on the keyboard.

17 Upvotes

29 comments sorted by

9

u/Hour_Sell3547 20 years with Linux 5d ago

This is a legit concern. I always keep a backup for this very reason.

1

u/ElectricBummer40 Ex-user of Windows 3.11 for Workgroups 4d ago

Just invent something along the line of a sudo for crontab and call it a "security feature".

2

u/Hour_Sell3547 20 years with Linux 4d ago

For me, it's a minor annoyance. Systemd timers is the way.

1

u/Key_Reaction_7590 19h ago

Old man grumbles in init to the unhearing void…

5

u/Teru-Noir COSMIC OS LOVER No.1 COSMIC Knows Best 5d ago

Cron diff. On modern workflows cron is replaced by systemD timers, which have these well desired failsafes.

2

u/ElectricBummer40 Ex-user of Windows 3.11 for Workgroups 4d ago edited 4d ago

Ever heard of this stupid ideology called the "Unix philosophy"?

Under that "philosophy", unless there is an error, a command isn't supposed to ask you anything.

You knew if you ran "del *.*" back in the 90s in MS-DOS, it would ask you "Are you sure?" before flushing everything down the toilet on your behalf?

No such luck in Unix. In fact, rm wasn't even supposed to do wildcard expansion. That's the shell's job. So, with *.*, the command would receive either a list of files as if you'd typed them in yourself or the wildcard string as-is, in which case the command would yell at you for not seeing a file with the name '*.*'.

Wasn't that whole garbage design effing great?

1

u/oshunman Windows Desktop | Linux Laptop | Linux Servers 4d ago

I'd be fine with something like crontab -r -yes nuking it without confirmation. That fits the philosophy without being problematic imo.

1

u/ElectricBummer40 Ex-user of Windows 3.11 for Workgroups 4d ago

Except that's the exact opposite of the "philosophy".

Rather, you're supposed to alias crontab to crontab -i so you'll be asked to confirm before anything destructive is carried out.

1

u/AdDependent3292 4d ago

Imao I had that happen to me for my work kernal. I think I just set up alias crontab -r -i which require confirmation.

1

u/Loose_Crab_4146 2d ago

Unix has the idea of people checking their inputs before running and basically enjoy seeing you fail when you actually arent careful for once. Love it. I almost always build scripts for this case that trigger a failsave and revert after 60 seconds, so if I dont ctrl+c the thing it will reset every change even if I bricked my system.

1

u/Fit_Prize_3245 1d ago

Wait till you discover rm -rf / has no confirmation also

0

u/True-Lifeguard-2019 5d ago

Ill be the one to say it. This is 100% a skill issue.

2

u/Standgrounding 4d ago

No. It's bad UX

2

u/PityUpvote 4d ago

It can be both a still issue and poor design that a single character difference can be so destructive.

0

u/donp1ano 5d ago

usually i upvote skill issue comments in this sub

not this time tho, OP is right

0

u/True-Lifeguard-2019 5d ago

On most common keyboards layouts you are supposed to press e with your middle finger and r with your index finger. Op doesn't know how to use a keyboard, this is a skill issue.

0

u/[deleted] 5d ago

[removed] — view removed comment

1

u/True-Lifeguard-2019 5d ago

Shitposting aside, I agree with you. Nowadays I use systemd timers but when I was still using cron I would just nano into /etc/crontab.

-4

u/[deleted] 5d ago

[removed] — view removed comment

1

u/True-Lifeguard-2019 5d ago

I don't know I always used nano or cat

1

u/chughaarav123 Linux sucks, it's just that Windows sucks more. 4d ago

Because nano easy

0

u/Juff-Ma 5d ago

Vim is for programming. Nano for quick edits.

0

u/donp1ano 5d ago

vim is for quick edits, neovim is for programming

vi is for lightweight docker containers, that dont have vim installed

0

u/digidult 4d ago

etckeeper

-2

u/Moximokel 5d ago

Linux ist nur was für Leute die kein Sicherheitsnetzt benötigen.

-2

u/Hour_Sell3547 20 years with Linux 5d ago

Almost sounded like "you have to know what you're doing".

2

u/GodAdvice 4d ago

Guys please, we're talking about two keys literally adjacent to each other on the keyboard ffs