TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Systemd.timer, an Alternative to Cron

84 点作者 bkq超过 2 年前

12 条评论

traverseda超过 2 年前
<a href="https:&#x2F;&#x2F;htmx.org&#x2F;essays&#x2F;locality-of-behaviour&#x2F;" rel="nofollow">https:&#x2F;&#x2F;htmx.org&#x2F;essays&#x2F;locality-of-behaviour&#x2F;</a><p>Locality of behavior is important. Note how this systemd-thingy is split into two separate files? It&#x27;s like that a lot in systemd, whoever is doing the architecture doesn&#x27;t seem to understand why locality of behavior would be desirable, instead taking the IDE approach of writing a bunch of tools to make managing the increased complexity more manageable. Don&#x27;t glance at a crontab to see when things will next execute, run some other tool that will inspect everything for you. Make things more complex and difficult to read, and then write tools to make it easier to read again.<p>They could have just added &quot;periodic&quot; service type that accepts timer options, and at least then it wouldn&#x27;t have to be two files.<p>Most of the advantages really don&#x27;t seem like advantages to me. Templated unit files seems especially silly since it&#x27;s equivalent to just copy and pasting a line in your crontab and changing an argument.<p>Seems to work for a lot of people, it&#x27;s just not to my tastes I guess. Still, I find the whole thing pretty mystifying.
评论 #33913249 未加载
评论 #33912925 未加载
评论 #33913769 未加载
评论 #33913402 未加载
评论 #33913081 未加载
评论 #33913735 未加载
评论 #33913122 未加载
评论 #33913564 未加载
评论 #33991856 未加载
评论 #33914757 未加载
评论 #33914527 未加载
评论 #33913631 未加载
评论 #33914820 未加载
luckycharms810超过 2 年前
While I agree Systemd timers aren&#x27;t as ergonomic to set up - there are some benefits that I would basically never give up at this point.<p>* Running the service on command ( this is the best way to troubleshoot issues with your slightly different environments &#x2F; cron&#x27;s version of shell. I&#x27;ve spent many minutes over my career - setting the crontab one minute and the future and waiting for it to run &#x2F; fail )<p>* Easily inspecting when the next run of the service is. ( list-timers )<p>* Straightforward access to the logs ( Always journalctl )<p>* Specifying environment variables easily<p>* OnFailure
评论 #33914099 未加载
评论 #33921722 未加载
sparker72678超过 2 年前
You can pry my crontab out of my cold, dead hands.<p>Seriously, though, cron has been so utterly reliable for me for so many decades now, it will be really hard for me to ever give it up.
评论 #33913301 未加载
评论 #33914576 未加载
评论 #33916042 未加载
评论 #33914780 未加载
评论 #33914070 未加载
pm90超过 2 年前
I&#x27;ve had the opportunity to delve into systemd in a previous role.<p>This sounds a bit weird, but its not easy to get started with, <i>unless</i> you&#x27;re used to reading man pages. But once you&#x27;re able to read man pages, all of systemd behavior is documented in the man pages. I do wish there were more human friendly docs though, especially for younger engineers used to better sorts of docs.<p>Anyways, once you do get the hang of it, its an immensely powerful system, but like any such system it has its quirks and edge cases. You can get 99% of what you need with it though, and for low level tasks on machines, its pretty amazing.
评论 #33914017 未加载
karlicoss超过 2 年前
Some time ago I wanted the best bits from both worlds:<p>- from cron: specifying all jobs in one file instead of scattering it across dosens of unit files. In 90% of cases I just want a regular schedule and the command, that&#x27;s it<p>- from systemd: mainly monitoring and logging. But also flexible timers, timeouts, resource management, dependencies -- for the remaining 10% of jobs which are a little more complicated<p>So I implemented a DSL which basically translates a python spec into systemd units -- that way I don&#x27;t have to remember systemd syntax and manually manage the unit files. At the same time I benefit from the simplicity of having everything in one place.<p>An extra bonus is that the &#x27;spec&#x27; is just normal python code<p>- you can define variables&#x2F;functions&#x2F;loops to avoid copy pasting<p>- you can use mypy to lint it before applying the changes<p>- I have multiple computers that share some jobs, so I simply have a &#x27;common.py&#x27; file which I import from `computer1.py` and `computer2.py` -- the whole thing is very flexible.<p>You can read more about it here:<p>- <a href="https:&#x2F;&#x2F;beepb00p.xyz&#x2F;scheduler.html" rel="nofollow">https:&#x2F;&#x2F;beepb00p.xyz&#x2F;scheduler.html</a><p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;karlicoss&#x2F;dron#what-does-it-do" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;karlicoss&#x2F;dron#what-does-it-do</a><p>I&#x27;ve been using this tool for several year now, with hundreds of different jobs across 3 computers, and it&#x27;s been working perfectly for me. One of the best quality of life improvements I&#x27;ve done for my personal infrastructure.
yamtaddle超过 2 年前
The one time I&#x27;ve tried to use this in anger, it said my script was running when it was supposed to and exiting cleanly, everything green, but <i>nothing</i> was happening.<p>Put it in cron, worked first try, and forgot about it.
dig1超过 2 年前
When I set up a new box, the first thing I do is disable all sorts of systemd-* nonsense, keeping systemd as an initd service only (which it should be). Then I replace them with serious, battle-tested tools like ntp&#x2F;chrony, unbound, etc...<p>It looks like systemd.timer will continue this practice ;) I&#x27;m expecting someone at Canonical&#x2F;IBM&#x2F;RH will be happy to put this as the default scheduler in the next distro release, marking it as a &quot;significant improvement&quot;.
ciupicri超过 2 年前
I don&#x27;t get the first argument. Put the whole command in a shell script and be done with it. You can easily run it anytime you want to.<p>Same with the last - templated unit files. Add a parameter or more to the script and you&#x27;re done.
whateveracct超过 2 年前
I quite like systemd timers with NixOS (configured in the Nix language). They&#x27;ve become a standard hammer for me.
评论 #33914327 未加载
评论 #33913972 未加载
tb_technical超过 2 年前
Why? Crob is simple, well understood, and works well. Why in god&#x27;s name do you want to reinvent the wheel?
评论 #33937161 未加载
评论 #33921642 未加载
exabrial超过 2 年前
&gt; Job output will automatically be written to systemd-journald<p>This is a bad thing, not something I’d boast about.<p>I actually really enjoy using systemd. Being able to start a process with complete isolation without heavyweight docker downloading mystery meat off the internet is a huge boon.<p>However, one thing systemd is logging. Jounalctl sucks. Grep, cat, etc, work infinitesimally better.
评论 #33937199 未加载
评论 #33918869 未加载
mnd999超过 2 年前
How long until we get the systemd kernel?
评论 #33913688 未加载
评论 #33914606 未加载