Crontab.guru – cron schedule expression editor
crontab.guru
crontab.guru
Part of my problem with committing the syntax to memory likely stems from the fact that I've always had pages like this one to fall back on.
Not having memorized cron syntax likely just means you don't work with it frequently enough for your brain to deem it worth the effort.
Doing something on every friday the 13th in the summer months is hard to program and test.
The textual representation is the best way to verify the syntax.
On debian based systems at least they use this to add an explanation and maybe dome examples. Never needed to check man pages since they started doing this.
Who trusts sensitive information like cron output to anonymous third parties? Is "but they are charging me, so I know I can trust them" the trigger here?
My name is Shane, and my co-founder is August. We did an indie hackers interview about Cronitor a few years ago and we’ve been pretty active here on HN.
I’m happy to answer any questions you have.
Or is it just an oversight and you didn't intend to run the service anonymously?
Over the years, as Cronitor grew into a successful business, we've shared a lot about it publicly with our names attached but I never felt a calling to put our faces on a webpage. I have always been more eager to collect customer testimonials and share what they have to say about us. Maybe I'm just shy.
Typically, I associate "we don't tell you who we are" with grey/black stuff. A DDOS service would only provide an email address for obvious reasons. But for a company? If somebody wants to sue you, they will find out who you are in any case. I wouldn't expect pictures, CVs etc, but a contact page that doesn't list a company/individual name and a street address triggers two feelings: a) scam or b) run from a bedroom. Neither makes me want to trust you with critical infrastructure (and here's where I'm irrational: seeing a company name and address is enough, unless there's some suspicion, I won't even dig into it to see whether the company or address actually exists).
As I mentioned, it's not specific to you at all, a lot of SaaS companies do this, and I don't understand it. Might be a cultural thing. In Germany, you're breaking the law if you're running a commercial site and are not clearly stating who you are, so maybe that's why alarms are ringing in my head when I don't see it.
I hope to add this feature soon.
https://stackoverflow.com/questions/30341067/difference-betw...
There are of course quite a few people who dislike systemd for justifiable reasons (but I doubt it receives the disdain that SELinux does), here's a starting point:
That said, I very much like systemd and I hope it isn't going anywhere. I think it's improved on a lot of things from the SysVinit days and I hope and believe that its shortcomings will be addressed and improved in the future.
So the super dismissive "systemd is better" response is kind of missing the point anyways, even with any type of legitimate justification.
(e.g. put all your logic in one script, test it with “env -“, lock exclusively with flock if you need it, or whatever else you have to hand in your language of choice.)
Package repo updates and Let's Encrypt renewals are a couple services I've seen use this. There isn't a great way to do this with cron that I know of, besides running some script that sleeps for a random duration.
That said, I still use cron for things that don't need this feature because it's portable and I'm just more familiar with it.
I hate this kind of syntax.
Well the actual syntax is even worse:
[Timer] OnBootSec=15min OnUnitActiveSec=1w
Instead, try GNU mcron (guile-based).
"The mcron program represents a complete re-think of the cron concept originally found in the Berkeley and AT&T unices, and subsequently rationalized by Paul Vixie. The original idea was to have a daemon that wakes up every minute, scans a set of files under a special directory, and determines from those files if any shell commands should be executed in this minute.
The new idea is to read the required command instructions, work out which command needs to be executed next, and then sleep until the inferred time has arrived. On waking the commands are run, and the time of the next command is computed. Furthermore, the specifications are written in scheme, allowing at the same time simple command execution instructions and very much more flexible ones to be composed than the original Vixie format. This has several useful advantages over the original idea. (Changes to user crontabs are signalled directly to mcron by the crontab program; cron must still scan the /etc/crontab file once every minute, although use of this file is highly discouraged and this behaviour can be turned off). "
https://www.gnu.org/software/mcron/manual/mcron.html#Introdu...
Given the narrowness of the domain is there a good reason not to use English?
For whatever reason it never works for me, including timers.
But I deploy a lot of services running as specific users and it works well. Good overview here:
https://wiki.archlinux.org/index.php/systemd/User
(You can install global services, and add `user=x`, etc, obviously. But I like to keep things self-contained.)
If you use *BSD, Jenkins, and everything else you use the standard cron syntax.
I'm so going to steal this
giving gold
Every time someone asks "why should I use systemd instead of cron" they get these (technically correct -- the best kind of correct!) answers about how systemd timers allow you to attach jobs to cgroups, define dependencies, test unit files separately vs. changing crontabs for 1 minute ahead (which I don't think is a "cron idiom" -- I've certainly never done i -- but we all have our weird hacks), and how it has built-in jitter options and per-job environment settings and whatnot.
These are all very relevant for real-life workloads of super advanced cloud systems, I'm sure. (Which I'm not saying in a derogatory way. I haven't written back-end code in like 12 years now, the things that are happening there today blow my mind. I know these are complex systems so I'm pretty sure they have complex problems which have complex solutions.)
But guys, I just need to run a bash script every day at 2 AM. 99% of us just need to run a bash script every day at 2 AM. This has worked reliably in cron since practically forever. I have grumpily learned the new way of doing it but I can't really justify the time I've put into it, nor the (very extensive) troubleshooting that was involved in it. I just woke up one morning and sat down in front of a Linux machine and I found out that there's a new way to run things at 2 AM.
If you want to woo me with cool systemd-timers features, tell me that it finally has an equivalent to cron's MAILTO, so that I don't have to write yet another systemd unit file that wraps a script written by me if I want to get a notification when a job has failed, because somehow that hasn't made its way into the "everything but the kitchen sink" list which otherwise includes things like attaching jobs to cgroups.
Until such a feature is implemented, you could try:
ExecStart=/bin/bash -c 'shopt -o pipefail; mycommand | mail -s foo@example.com'
Certainly not as convenient as MailTo=, but a lot less complicated than using OnFailure= with a separate service that tries to mail you the output.
But to be honest, not having to do <shell> -c <exec this or send me an email> ever again is one of the reasons why we're doing the whole systemd thing, and one of its big promises. If it comes to writing shell mantras again, I might as well use vixie cron (or one of its descendants) and benefit from 30+ years of bugfixes across more Unices than I can name, plus the acquired wisdom of the Interwebs.
Edit: plus... does this still allow you to get the other goodies, like being able to specify environment variables for a specific job?
As for 'exec this or send me an email' -- I would also much prefer to see this be done by systemd itself. Fortunately bash's 'pipefail' feature plus bsd-mailx's '-s' flag make this reasonably quick and sane; I wouldn't even bother to attempt it if I were stuck with POSIX sh or if the mail command lacked the logic to not send the mail if stdin is empty.
I thought that environment variable passed via the Environment= options might not be correctly set, but it seems they are :-).
That's a lie. A mail is sent on failed jobs. The receiving mailbox is by default the executing user (so usually root) There is also an entry into the systemlog which should already be monitored.
The user might not get the notifications because he doesn't pay attention, but cron does notify.
I have deployed many Ubuntu boxes and sometimes been surprised to receive emails - cron (logwatch) usually. Our central SMTP daemon has me as an alias for root, postmaster etc. Don't know why I'm surprised - I set the bloody things up to work - perhaps I'm going a bit senior.
If the messages are going out they probably use an MTA and are logging in to a hosted service, which is something that needs to be set up.
DKIM is the second of the trifecta, SPF first and then DMARC after DKIM. DMARC is when things start to go horribly wrong or wrongerer than normal in the world of email. Mailing lists get funky shortly after you proudly publish a TXT record starting "v=DMARC1; and p=<unwise choice>.
I'm not sure that state of the art is appropriate when describing SMTP. It is what it is and no more, nor less. It transfers a huge amount of data daily, without fuss or comment. Perhaps that is the state of the art - it is in my world: I like stable and boring and just works.
I'm (nearly) a Civil Engineer and I think of SMTP as an odd analogy for concrete. It's fundamental and very boring but can be surprisingly complicated and interesting if you get it wrong. Conc. can burn or get tricky in all sorts of ways if poured in excessive amounts - setting is an exothermic reaction and will work under water as well. Conc can suffer from concrete cancer which is where sea air and a few other factors causes "map cracking" and potentially failure. SMTP is another function that is dumped into the background, forgotten about and relied upon to just work until the wheels fall off.
By who? This isn't even almost true.
Local-only (outside of Debian) is generally only found on desktop- or hobby-oriented Linux things like Fedora and Arch -- which aren't really germane here.
But that local MTA you have is not typically something you log in to check your mail, and all of these things are not set up by default.
I'm having a hard time understanding you because you refuse to specify "what needs to be set up" and when you have you've been mistaken.
LAN sending is not being "phased out". Email is not being "phased out". Nothing has changed with email policies on any of these distros for the better part of a decade.
What are you trying to say?
Of course this is not useful unless you ssh in and read the mail.
But then mail shouldn't be used for notification anyway, so this is not a big deal.
It takes some configuring to make sure crown sends emails to the right place - and without the email going straight to spam. Sure you can setup filters, etc. But that's manual work. Not to mention of you'd rather have it text you, send a message to slack etc.
Also cron can't alert you if you accidentally removed the cron job, the host is down, host loses its connection etc.
Of course they're tested, and you're right they've worked fine for a looooong time.
But I don't care if they "normally work fine", I need to know immediately if it didn't run for any reason. We self hosted a cron monitor, it was free and only took less then a day to add and have fully integrated, including text message and MS teams notifications.
Please don't use the lie word: it goes to intentionality. It's wrong, true: Cron has (for a very long time) been designed to mail and log on failure.
The thing is that a huge number of deployments these days don't run functional mail send, and so the failure states go to /dev/null (in effect)
Also, cron can fail to run: Linux moved cron to a different execution state from BSD, which has also introduced (on linux) the interaction between cron and anacron. Changing the state of cron.d/ doesn't always register in cron, and cron won't always send mail if it doesn't know new things have to be run. The older crontab -e method reliably made cron re-read the state of the file.
(I think this predated Vixie cron, cron existed since time immemorial in UNIXEN. Vix improved things, but the underlying system behaviour was established before he coded in this space)
If someone built a whole product around it - and use it as their marketing pitch when it takes like 30 seconds of man-page reading to find out that it's wrong, I'd argue you have some fairly good reason to assume intentionality.
(That said, yes, I agree that there are failure states in traditional cron that won't alert you with an email, so the service might of course be useful.)