Cron checker
crontab.guru
crontab.guru
Those are all database functions. In UNIX/Linux, each configuration file has its own mechanism for all that. They're all inferior to SQLite.
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.
Cron ticks every minute and checks to see if any crontab entries match the current time, if so it runs the job. But standard regular expressions aren't well suited to the types of patterns people normally try to express which is why they use their own syntax.
Unix programmers aren't in the habit of throwing out a working system because it's hard to grok, nor building something more complex then it needs to be. I took a look at your systemd timers link and it is a more complex syntax to create the same effect. From their own caveats section:
> Complexity: to set up a timed job with systemd you create two files and run a couple systemctl commands. Compare that to adding a single line to a crontab.
I've spent the past years doing that. I do understand cron. I also strongly dislike it. You could build a thriving city within the bounds of the room there is for improvement.
> It even handles that crazy case where you want to run on a specific day of the week.
So does systemd's cron. Supporting "crazy cases" doesn't mean the syntax has to suck.
> Cron lines may seem arcane at first, but then again have you ever tried to write code that was timezone aware?
Yes...
Re systemd: It's one example; it's not perfect, I wouldn't even call it good, but it's leagues ahead of cron in terms of UX already. Bonus: usage of the ini format means it's programmatically much easier to interact with the cronjob itself.
But a simple GUI could take care of that.
appstartup.sh | tee -a app.`date +%Y%m%d`.logDoes it handle the, in my opinion, not crazy case of running something every, say, 100 seconds?
*/100 * * * * echo "every 100 mins"I have a similar problem with "every 2 days". */2 looks simple enough, but it fires on the 29th, miss 30th, fires on 31st, then fires the 1st. 3 times in 4 days isn't "every 2 days".
Cron only works for periods which are evenly divisible into the calendar. "every 7 minutes" doesn't work because 60 isn't evenly divisible by 7. "every 5 hours" doesn't work (in that it'll match 8pm and midnight, which are only 4 hours apart), etc.
But you probably can tweak your requirement slightly.
@100 /do/my/thing.shWatch your language!
*/1 * * * * /usr/bin/bash -c '[[ $(( $(/usr/bin/date +%s) % 6000)) -eq 0 ]] && mycommand'Why is having the format be so concise and terse a virtue?
They could keep the flat file approach and everything about the system identical but just make it more explicit. Cron usage would become much simpler.
Cron could be considered as a good mix between complexity and brevity (readability).
Shameless plug: I tried to create a format in-between both in a JS project [1]. It is based on the ISO 8601 duration format [2], but it's better to stick to iCalendar.
[0] https://tools.ietf.org/html/rfc2445#section-4.3.10
http://pubs.opengroup.org/onlinepubs/7908799/xcu/crontab.htm...
In a sense, crontabs are the lowest common denominator for scheduling tasks on POSIX-compliant systems.
Killing off old designs is exceptionally difficult for Unix. Hell, Microsoft can barely force an upgrade on everyone and they don't have a hundred forked distros.
The syntax of cron isn't the most intuitive but it's powerful and would make even less sense in a database.
I don't think a database would offer anything unless it was managing 1000's of cron servers. Flat text is fine and easier to parse than querying a database and adding a dependency. A database is a huge requirement to ask for to manage a few simple files.
Also the tools argument just isn't true. A well designed plain text format is easier to parse with a one-off parser than with ugly one-off SQL queries. The reason that not many GUIs exist for plain text formats is that they are already designed to be easy to use. There are few cases where GUIs make sense.
From the top of my head, the only configuration GUI I regularly use is firefox's. Not that it wouldn't be possible to come up with a clean plain text design that would be easier to use.
Also most of the stuff is not represantable as relations. I'm looking forward to see how you encode a shell command in relations.
Just because Windows' registry is hard to manually edit doesn't mean they are a bad idea. Look at how much better Windows' GUI configuration tools are than anything on Linux. They all use the registry.
That's not the problem with Windows registry.
> That's not the problem with Windows registry.
What is?
> My life would be a heck of a lot easier if per-application settings were stored in a place I could easily see them, manipulate them, and back them up. Like, say... in INI files.
> The registry is opaque and binary. As much as I dislike the angle bracket tax, at least XML config files are reasonably human-readable, and they allow as many comments as you see fit.
Now look at the comment you replied to:
> Just because Windows' registry is hard to manually edit doesn't mean they are a bad idea.
You said that's not the problem with the registry, but your own link says that's exactly the problem with the registry...
An associated problem is that the registry accretes trash that is never weeded out (and it's hard to weed it out).
Also at least in former times it was slow (partly because of the trash thing, probably partly because of the implementation, partly because of the centralised design).
with reg query, reg export and reg import commands, respectively. Or with a few clicks in the GUI, if you prefer.
> ...accretes trash
If your app doesn't remove it's old settings when uninstalled how is that a problem for the registry to solve? It happens with /etc also.
> hard to weed it out
Search for the hives if you don't know where they are. Right-click the hives in question, delete.
Registry usability got leaps and bounds better in Windows 7, and again in Windows 10. Most registry problems you hear about are holdovers from the bad old days (XP and older).
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.
Which itself has all sorts of complications around locking. Can't write when another process has read-only lock, for example:
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.
Someone edits a cron file in the most common editor, vim. On many systems it doesn't do an atomic swap on save without extra configuration: http://stackoverflow.com/questions/13563627/how-does-vim-sav...
Now maybe your unresponsive, undergoing swap, system misses a cron job that was present in both edits. Opps.
I'm not sure this could really play out, but the approach definitely sounds firmly on the "worse is better" side of the scale.
Otherwise adding a file or deleting a file in /etc/cron.d/ is the way to go for automatic(ansbile, puppet etc) and package installations.
However crontab -r has to be one of the most poorly thought out commands in UNIX. It removes the cron file and since r is only one character over from e on qwerty keyboards it's a painful and surprising typo.
2. Puppet handled that parsing for you and will throw errors if your syntax is wrong
Honestly though, I never use `-e` either. I keep a ~/.crontab and edit that, and then `crontab ~/.crontab`.
Voila, backup/time machine/git friendly crontab.
Instead of per-user crontabs. Much easier to manage.
With cron.d you can specify what user each cron entry should run as, so it is equivalent.
And there's "vipw" for the password file. Each of them with their own separate updating bugs.
Nobody argues that there can't be problems. What all critics miss is to show how to avoid these problems.
What can you do about jobs that make the system unresponsive? Not a problem for cron to solve.
If someone writes a crontab (instead of rename()ing another version over it), that's not cron's fault. Sqlite databases can be just as easily corrupted or lose integrity. Now which format would you rather repair?
Missing a cron job can not be totally avoided, and it isn't the end of the world. What if your machine goes down or cron crashes? The answer is that the jobs themselves have to be provided with some resilience against that situation.
This isn't a case of "worse is better" since there weren't proposed solutions to the "problems" at all, however unrealistic.
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).
In UNIX, everything is a file
Do you see a pattern?
Create a process in the same manner. Oh, again you can't do that. What a shame.
And with route and user account examples you confuse being a file and being a record in a file (which, couriously, is not a file itself).
Granted, it's not possible to change IPv6 address through /proc/net/if_inet6, but just because I don't know about it, doesn't mean that it isn't possible.
No. It's a configuration file for a separate set of tools that actually configure the interface for you. You can't set its current IP address by writing to any file.
> I can set tx queue length of eth0 to 300 packets: echo 300 > /sys/class/net/eth0/tx_queue_len Or change frame forwarding behavior from switch to hub: cat 0x65535 > /sys/class/net/vnet0_11/bridge/group_fwd_mask
Sorry, no banana; you only can control two or three aspects this way, and not the most fundamental ones at that.
Network interface is simply not a file, it's a separate OS-level construct, it's not exposed to userland as a file. Not everything in Linux or unix is a file, even though many things (the ones more remote from kernel) are.
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.
Makes sense.
Have you tried any of these answers?
http://stackoverflow.com/questions/2135478/how-to-simulate-t...
env - HOME=$HOME LOGNAME=$LOGNAME sh -c 'command line'
Home, shell and logname are the only 3 variables guaranteed to be set.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.
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
5 4 W * *
Really gave Chrome some grief.> Really gave Chrome some grief.
You are evil.
It also gave Firefox a lot of grief. CPU usage shot to 100%.
[0] 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
0/5 * * * *
as it does for */5 * * * *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
All other fields are AND together, these two are OR
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.
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.
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.
Here's what I'd call a simple init.d-like example. non-needed things (if you think it's too complex) include: wait for fs mount and network, custom reload command, "don't log stdout"
[Unit]
After=network.target
AssertPathIsMountPoint=/mnt/service-data-if-needed
[Service]
ExecStart=/some/binary
Environment=CONF=/etc/i/guess.conf USER=nonrootmaybe
ExecReload=/bin/pkill binary
KillMode=process
Restart=always
StandardOutput=null
[Install]
WantedBy=multi-user.target
EDIT: man 5 systemd.unitIf we're comparing running a binary on startup vs. setting it up as a service in systemd, I wholeheartedly agree that you should always use the right tool for the job. So let's discuss the software, not the politics :)
If we're talking about the original story (crontab) people should compare it to systemd timers if they're looking for alternatives - which I still prefer.
I have no stake in OSes choice of default installed packages (be it init, openrc, or systemd), and agree with your parent comment that OSes shouldn't break (dropping crontab as an installed base package) without consideration.
I haven't come across one of these OSes where it wasn't possible to install crontab from their default package managers, and in their main repositories, though.
About the timers in systemd I haven't even look at them. As long as I don't need them I'm fine with 'cron' and 'at'. Maybe they are not the best posible systems, but IMO work quite well (and I don't have to change my code to use them). If at some point I encounter problems or limitations with my uses of cron and those are fixed by systemd I will happily update to systemd timers. For now the work perfectly fine for my needs.
That only guarantees that your network devices have been enumerated, not that they are available with assigned addresses.
I encountered this problem with SSH failing to start on Ubuntu 16.04 server. systemd was launching SSH before the binding address had been assigned, causing SSH to abort and fail and the server to continue to boot without any way of accessing it remotely.
Workaround ( at the physical console ) was to add a Retry to the SSH unit and time it to coincide with the address having been assigned[0]. hacky, but no other unit imperatives worked.
[0] Default behaviour in the SSH unit, at least on Ubuntu, is that it tries once and never again.
Also, i expect the faithful to come and claim it is a Canonical fuckup.