This is why the UNIX approach of using flat text files for dynamic information is obsolete. It seems so simple to have a text file. But then you need an editor, a locking system, access control, and a checker. And probably something to remove orphaned lock files and detect corrupted data.
Those are all database functions. In UNIX/Linux, each configuration file has its own mechanism for all that. They're all inferior to SQLite.
Crontab is an excellent example of situations where text files are superior. You are welcome to try to design a database schema that is safer or easier to use.
Most of the things living under /etc are not databases. crontab certainly isn't:
- Only a single "table" (no table-relations)
- No standard database type exists for columns (how would you model the scheduling as database types, how would you model the shell command as database types, if not simply as sanitized strings)
So you can't get integrity for free. Need a custom parser and some integrity checks. Not so difficult (yes, cron will give instant feedback for the unlikely case that you did something wrong)
Re: editor, locking, access control:
I have an editor and prefer it to writing SQL DML any day.
File updates (rename(2)) are atomic, so no need for additional locking. And even if there is some broken tool writing to the old file instead of rename, the chances of that being simultaneous with a parse are microscopic. Don't overdesign. (there are many more things that can go wrong in a system that you can't possibly design out. Live with it).
Access control: Standard file permission modes are just fine. More complex permission model would be a serious overdesign. You can get granularity by using separate crontabs.
Checker: Never needed an additional tool to format the meaning as human-readable text. The syntax is a bit ugly but quite easy to remember and use.
Editor: of course you need some way to input data, and an editor is the simplest interface. You need to generate SQL to store data in SQLite and that's certainly not simpler.
Locking system: the OS/filesystem can provide this just as well as a database can.
Access control: same answer
Checker: input needs to be validated for its intended task and SQLite won't magically make this requirement disappear.
Can someone explain to me how crontabs, and cron syntax, are still so popular and one of very few options available?
It's not like crontabs are written all the time. They don't need to be so terse. They shouldn't require learning a language... they shouldn't require a cron.guru website. Systemd timer syntax (https://wiki.archlinux.org/index.php/Systemd/Timers#Example) is far more readable, and there's still a lot of room for improvement.
No, it is NOT a problem of using flat files. It is a problem of using files. The files are the serialized initial values for the run-time configuration, which may or may not be changed. SQLite is no superior to flat files in that, and in fact, can be damaging if the user managed to break the invariant and the invariant is not checked.
The configuration system absolutely demands the locking system (to alter it) and the checker (to correctly check if it is correct before the changes are ever committed). SQLite can provide some of them, but not all---most importantly, SQLite's locking system is independent of the runtime configuration which requires separate locking system (however rudimentary).
What I'd like is a way to check that the command will run properly. Waiting for one minute to test is not productive at all. And no, testing in your shell won't do, since cron runs in a particular environment.
Crontab generator [0] is a good alternative that doesn't feature broken JS [1]. Moreover, the example and configuration page on the wikipedia page [2] are clear enough.
Why just not replace cron with something a bit more flexible in terms of settings and config formats? Seriously, I guess time spent on making this website should be coparable with rewriting cron — it's not like cron is a complicated piece of software.
Not everybody has systemd. The BSDs don't (iirc), and for example we are stuck with some Debian Wheezy host at $work, which don't come with systemd either.
Also, lots of operators have decades of experience with cron, and don't want to give up on that easily.
A lot of people who are familiar with cron already, but not with systemd.
But, to be honest, writing crontab is easier task, systemd timers are not more intuitive than cron when you write them, i.e. I personally still look in documentation for various systemd options, but are IMHO much easier to read and more powerful, and have great "systemctl list-timers" view, but unfortunately not superset of crontab options. That's probably the second reason to still use crontab.
So, obviously systemd has also taken over crontab?
My god ...
Really this is sick. I've to fight systemd to do some dead simple init.d custom services and it was awful. Even the process resource limits had to be setup in the sytemd config files.
I like /etc/crontab. It is a simple text file. Nothing magic. Standard. Works every time. Well known by everybody.
Works on a lot of UNIXes, old Linux systems etc.
I don't want no new complexity and a new way to do things every 6 months. What I hate most is that all this is pushed through our throats no matter what we want. FFS.
EDIT: BTW, I think luckily, /etc/crontab at least currently still works on Ubuntu Server 16.04 (what I've tried). I think this is the way to go. If you want to use some new features (systemd) you can opt-in. But don't break old stuff please.
yeah I agree with Tip #5 at least for a server environment, there are better ways to run things on reboot that need to run on reboot, although for those in the anacron camp, I suppose this level of randomness would appeal / appear entirely reasonable :)
[+] [-] Animats|9 years ago|reply
Those are all database functions. In UNIX/Linux, each configuration file has its own mechanism for all that. They're all inferior to SQLite.
[+] [-] jstimpfle|9 years ago|reply
Most of the things living under /etc are not databases. crontab certainly isn't:
- Only a single "table" (no table-relations)
- No standard database type exists for columns (how would you model the scheduling as database types, how would you model the shell command as database types, if not simply as sanitized strings)
So you can't get integrity for free. Need a custom parser and some integrity checks. Not so difficult (yes, cron will give instant feedback for the unlikely case that you did something wrong)
Re: editor, locking, access control:
I have an editor and prefer it to writing SQL DML any day.
File updates (rename(2)) are atomic, so no need for additional locking. And even if there is some broken tool writing to the old file instead of rename, the chances of that being simultaneous with a parse are microscopic. Don't overdesign. (there are many more things that can go wrong in a system that you can't possibly design out. Live with it).
Access control: Standard file permission modes are just fine. More complex permission model would be a serious overdesign. You can get granularity by using separate crontabs.
Checker: Never needed an additional tool to format the meaning as human-readable text. The syntax is a bit ugly but quite easy to remember and use.
[+] [-] ckastner|9 years ago|reply
Editor: of course you need some way to input data, and an editor is the simplest interface. You need to generate SQL to store data in SQLite and that's certainly not simpler.
Locking system: the OS/filesystem can provide this just as well as a database can.
Access control: same answer
Checker: input needs to be validated for its intended task and SQLite won't magically make this requirement disappear.
[+] [-] edoceo|9 years ago|reply
Or did we not read the manual, then complain about broken stuff and follow that with an over-enginered "solution" to a problem that didn't exist.
[+] [-] Spivak|9 years ago|reply
The syntax of cron isn't the most intuitive but it's powerful and would make even less sense in a database.
[+] [-] scrollaway|9 years ago|reply
It's not like crontabs are written all the time. They don't need to be so terse. They shouldn't require learning a language... they shouldn't require a cron.guru website. Systemd timer syntax (https://wiki.archlinux.org/index.php/Systemd/Timers#Example) is far more readable, and there's still a lot of room for improvement.
[+] [-] lifthrasiir|9 years ago|reply
The configuration system absolutely demands the locking system (to alter it) and the checker (to correctly check if it is correct before the changes are ever committed). SQLite can provide some of them, but not all---most importantly, SQLite's locking system is independent of the runtime configuration which requires separate locking system (however rudimentary).
[+] [-] olgeni|9 years ago|reply
[+] [-] eli|9 years ago|reply
[+] [-] dingaling|9 years ago|reply
Which itself has all sorts of complications around locking. Can't write when another process has read-only lock, for example:
https://www.sqlite.org/lockingv3.html
[+] [-] xorcist|9 years ago|reply
Makes sense.
[+] [-] agumonkey|9 years ago|reply
[+] [-] joelthelion|9 years ago|reply
[+] [-] chrisan|9 years ago|reply
Have you tried any of these answers?
http://stackoverflow.com/questions/2135478/how-to-simulate-t...
[+] [-] CraigJPerry|9 years ago|reply
[+] [-] taphangum|9 years ago|reply
[+] [-] userbinator|9 years ago|reply
You could simply find something else to do for a minute, like rechecking that the other pieces of the system are setup correctly as well.
[+] [-] ajmurmann|9 years ago|reply
[+] [-] faaabio1618|9 years ago|reply
cronwtf:
0 0 1 1 0 COMMAND Runs `COMMAND` at minute :00, on hour 0, on day 1, in Feb, on Sun.<-- NO!
crontab:
0 0 1 1 0 At 00:00 on the 1st and every Sun in Jan. <-- CORRECT
[+] [-] thomseddon|9 years ago|reply
[+] [-] taspeotis|9 years ago|reply
[+] [-] 0xmohit|9 years ago|reply
> Really gave Chrome some grief.
You are evil.
It also gave Firefox a lot of grief. CPU usage shot to 100%.
[+] [-] kowdermeister|9 years ago|reply
[+] [-] 0xmohit|9 years ago|reply
[0] http://crontab-generator.org/
[1] https://news.ycombinator.com/item?id=12105516
[2] https://en.wikipedia.org/wiki/Cron
[+] [-] unchaotic|9 years ago|reply
http://www.cronmaker.com/
http://crontab-generator.org/
http://www.openjs.com/scripts/jslibrary/demos/crontab.php
http://htmlminifiers.com/cron-maker.php
http://cron.nmonitoring.com/cron-generator.html
https://crontranslator.appspot.com/
http://cron.schlitt.info/
[+] [-] agumonkey|9 years ago|reply
http://crontab.guru/#*_5/6_*_*_*
[+] [-] webreac|9 years ago|reply
[+] [-] krzrak|9 years ago|reply
[+] [-] lugus35|9 years ago|reply
[+] [-] Pamar|9 years ago|reply
[+] [-] krick|9 years ago|reply
[+] [-] michaelmrose|9 years ago|reply
[+] [-] pekeler|9 years ago|reply
[+] [-] fideloper|9 years ago|reply
[+] [-] gourneau|9 years ago|reply
If any of y'all are looking for a more modern cron replacement for running periodic tasks with a nice web uis here are a few other options:
* Rundeck http://rundeck.org/ * Stackstorm https://docs.stackstorm.com * ndscheduler https://github.com/Nextdoor/ndscheduler
[+] [-] CraigJPerry|9 years ago|reply
All other fields are AND together, these two are OR
[+] [-] unknown|9 years ago|reply
[deleted]
[+] [-] boot13|9 years ago|reply
[+] [-] mangix|9 years ago|reply
[+] [-] perlgeek|9 years ago|reply
Also, lots of operators have decades of experience with cron, and don't want to give up on that easily.
[Update] After reading https://wiki.archlinux.org/index.php/Systemd/Timers I see two more reasons
* You don't have to write a service file to use cron jobs, which makes ad-hoc tasks much easier
* Sending mails is the default for cron, which requires extra work with systemd.
[+] [-] adontz|9 years ago|reply
But, to be honest, writing crontab is easier task, systemd timers are not more intuitive than cron when you write them, i.e. I personally still look in documentation for various systemd options, but are IMHO much easier to read and more powerful, and have great "systemctl list-timers" view, but unfortunately not superset of crontab options. That's probably the second reason to still use crontab.
[+] [-] int0x80|9 years ago|reply
I like /etc/crontab. It is a simple text file. Nothing magic. Standard. Works every time. Well known by everybody. Works on a lot of UNIXes, old Linux systems etc.
I don't want no new complexity and a new way to do things every 6 months. What I hate most is that all this is pushed through our throats no matter what we want. FFS.
EDIT: BTW, I think luckily, /etc/crontab at least currently still works on Ubuntu Server 16.04 (what I've tried). I think this is the way to go. If you want to use some new features (systemd) you can opt-in. But don't break old stuff please.
[+] [-] yoavm|9 years ago|reply
[+] [-] kseistrup|9 years ago|reply
[+] [-] efiala|9 years ago|reply