DEV Community

Hye Jin
Hye Jin

Posted on

crontab -; ?

I just had a weird experience and wanted to share it here to ask if anyone had a similar experience.

In the linux server, I was working on my crontab. My original plan was to type crontab with the option -l but I typed in my terminal as below.

crontab -;
Enter fullscreen mode Exit fullscreen mode

The command above delete all the cron jobs I had and didn't leave anything. I couldn't find any blog or posts about the above command doing something. What could be the behind logic of this?!

Top comments (2)

Collapse
 
devtalhaakbar profile image
Muhammad Talha Akbar • Edited

Hope it wasn't a production server. Otherwise, it's hilarious.

From the manpage, the crontab has two forms:

crontab [-u user] file
crontab [-u user] { -l | -r | -e }
Enter fullscreen mode Exit fullscreen mode

The first form of this command is used to install a new crontab from some named file or standard input if the pseudo-filename `-' is given.

It's possible the command above got interpreted as the first form and a new crontab with just ; inside of it was installed.

Apart from guess above, I have no idea. But, it's interesting. Glad I am no longer around servers.

Collapse
 
spwlsldi profile image
Hye Jin

Thanks for the reply! Well thankfully we were working in our development server so everyone is safe!

I wasn't aware of the first form so it's something new for me that I need to look up. Thanks for the help!