Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
chadbear
Jan 15, 2020

I once wrote a script that created/started/stopped a user-service in systemd. It was… fine? I definitely encountered more bullshit using other systems. I am not a sysadmin though.

Adbot
ADBOT LOVES YOU

FAT32 SHAMER
Aug 16, 2012



Systemd was much easier for me to run a daemon than any other thing I had used in the past. It’s Fine™

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

pseudorandom name posted:

He's not a douche, he's German.

he is absolutely both

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

systemd makes more things declarative and subject to mechanical analysis, and given the complexity of service lifecycles on a modern Linux that’s pretty critical for making things even halfway comprehensible

but you do have to actually learn it, instead of just making a file under /etc with the same commands you used to start the thing manually

and the name “quadlet”…

xzzy
Mar 5, 2009

Subjunctive posted:

and the name “quadlet”…

It's a stupid Kubernetes pun but at least it googles well I guess.

Unlike say the "ip" command.

Inceltown
Aug 6, 2019

xzzy posted:

It's a stupid Kubernetes pun but at least it googles well I guess.

Unlike say the "ip" command.

*googled well

Google has gone to poo poo and nothing googles well anymore.

keep punching joe
Jan 22, 2006

Die Satan!

Framboise posted:

As a newer Linux user: is systemd really that bad?

Still waiting to upgrade my PC before I get into using Linux full time. I can't install most distros on this machine for whatever goddamn reason, so it's time to just get something new.

Normal people do not think about or care about the init system that's in use on their system. I don't even understand the complaints about Systemd, that it does a lot of separate things rather than one single thing? That is 'bloat'?

A lot of people bitch about Wayland too, but there's probably good reason for that if it just doesn't work properly for their specific use case.

Framboise
Sep 21, 2014

To make yourself feel better, you make it so you'll never give in to your forevers and live for always.


Lipstick Apathy

Inceltown posted:

*googled well

Google has gone to poo poo and nothing googles well anymore.

I have been trying to un-Google myself all year and while I've switched from Chrome to Firefox and set my search settings to DuckDuckGo, I feel like it's pretty inescapable so long as I'm still using an Android phone and use a gmail account (and I don't have the nerve to make a new email address since I've been using this one since like 2007). Can't stand iPhone's interface though, so whatyagonnado.

Thankfully, un-Microsofting will be much easier once I can move over to Linux. My issue's more with my PC than my willingness or ability to do so though.

keep punching joe posted:

Normal people do not think about or care about the init system that's in use on their system. I don't even understand the complaints about Systemd, that it does a lot of separate things rather than one single thing? That is 'bloat'?

A lot of people bitch about Wayland too, but there's probably good reason for that if it just doesn't work properly for their specific use case.

Yeah, that was my understanding of it before asking here earlier, "it handles a bunch of things instead of just one". Like I get the idea of minimalism and having a program do one thing real good being ideal and stuff, but I dunno, having a program that's able to handle many things sounds efficient to me?

Framboise fucked around with this message at 08:39 on May 19, 2024

VictualSquid
Feb 29, 2012

Gently enveloping the target with indiscriminate love.
I do think that the only legitimate complaint is that systemd's documentation sucks. Most other complaints are mostly people complaining about learning new things and making excuses.

Though I feel like there is a gap where Systemd is an improvement for developers and casual users, but it is equal or worse for amateur tinkerers.

For example if you want to make a minor modification to a script in your system-v the automation is written in bash just like your script and you open the file and change that one line. Which breaks easily.
For systemd you have to create an overwrite file and write it from scratch using a syntax that you don't know and that has its documentation spread over a dozen help files. And you still need to learn bash for the actual script.
Now these days there is a overwrite file editor that shows you the defaults as comments, making that editing much easier. But, it didn't exist in the beginning. And as the most accessible source for systemd syntax are random outdated answers on stackexchange, you might not even know about the feature.

Also people do tell you to write unit files. Just complain about anything related to cron, and people will tell you to "just" write a timer file and an unit file from scratch instead of changing a config options in cron.

Klyith
Aug 3, 2007

GBS Pledge Week
The Unix philosophy is a program should do one thing and do it well.

Systemd does one thing and does it well. It manages the system. Perfectly compliant with unix philosophy.



VictualSquid posted:

Though I feel like there is a gap where Systemd is an improvement for developers and casual users, but it is equal or worse for amateur tinkerers.

For example if you want to make a minor modification to a script in your system-v the automation is written in bash just like your script and you open the file and change that one line. Which breaks easily.

Maybe, but also the whole drop-in configs is a systemd thing isn't it? Being able to manage /etc by adding 69-myconfig.conf as an isolated and unique file is really nice for the intro-level tinker. It makes the changes you've done to the system almost self-documenting. (And very easy to back up if you use a particular prefix for your own configs.)


VictualSquid posted:

Also people do tell you to write unit files. Just complain about anything related to cron, and people will tell you to "just" write a timer file and an unit file from scratch instead of changing a config options in cron.

So as someone who was new to all of this, I didn't see much difference in complexity between making a systemd timer and cron. They both have some different pros and cons. Systemd timers are not that hard. You just know cron already.

But yeah the official documentation sucks.

VictualSquid
Feb 29, 2012

Gently enveloping the target with indiscriminate love.

Klyith posted:

Maybe, but also the whole drop-in configs is a systemd thing isn't it? Being able to manage /etc by adding 69-myconfig.conf as an isolated and unique file is really nice for the intro-level tinker. It makes the changes you've done to the system almost self-documenting. (And very easy to back up if you use a particular prefix for your own configs.)

I think the drop-in configs started with udev, before systemd. Or possibly were backported to system-v, because they are a good idea.
I personally found them harder to get into, because you start with an empty file instead of changing an already existing config line which feel like more mental effort to me.
Which is why I think that systemd's biggest improvement was pre-populating drop-in files. And I think that they added that only after the peak of complaining prolonged the complaining massively.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

VictualSquid posted:

I think the drop-in configs started with udev, before systemd. Or possibly were backported to system-v, because they are a good idea.
I personally found them harder to get into, because you start with an empty file instead of changing an already existing config line which feel like more mental effort to me.
Which is why I think that systemd's biggest improvement was pre-populating drop-in files. And I think that they added that only after the peak of complaining prolonged the complaining massively.

Drop-in configs were a thing for Apache before udev existed, IIRC.

mystes
May 31, 2006

VictualSquid posted:

Also people do tell you to write unit files. Just complain about anything related to cron, and people will tell you to "just" write a timer file and an unit file from scratch instead of changing a config options in cron.
Cron is the worst thing ever created

cruft
Oct 25, 2007

mystes posted:

Cron is the worst thing ever created

Just write a timer file and an unit file from scratch instead of changing a config options in cron.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

but you don’t have to do that, because the tools generate pretty much all of it and there’s an LSP

it’s not like cron fuckups taking out a service is even uncommon today, but especially before crond grew jitter and such

VictualSquid
Feb 29, 2012

Gently enveloping the target with indiscriminate love.

Subjunctive posted:

but you don’t have to do that, because the tools generate pretty much all of it and there’s an LSP

it’s not like cron fuckups taking out a service is even uncommon today, but especially before crond grew jitter and such

Which tools? And what is an LSP?
And that brings us back to the fact that the big legitimate complaint about systemd is it's terrible documentation.

Klyith
Aug 3, 2007

GBS Pledge Week
"write a config from scratch" makes it sound really hard when all you are doing is copy-pasting ~13 lines of text, if you are making something with the same level of capability as cron.

code:
[Unit]
Description=foobar user service

[Service]
Type=simple
ExecStart=%h/script/foobar.sh

[Install]
WantedBy=default.target
code:
[Unit]
Description=timer for foobar service

[Timer]
OnCalendar=Mon,Wed,Fri *-*-* 00:00

[Install]
WantedBy=timers.target
That's it!


Note that you can have multiple OnCalendar lines, which makes complicated timers way easier than cron. Though I've heard that cron can do times that systemd can't, if you want some real phase-of-the-moon poo poo.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

ah, I thought systemd-cron was part of the core systemd stuff, but I guess not. an LSP (Language Server Protocol [service]) is a program that tells an editor or similar tool how to work with a given source language: syntax highlighting, autocomplete, refactorings, etc. there are some for systemd to help if you aren’t familiar with it

crontab for a user is easy as long as what you want is very simple, and you don’t mind weird errors when it’s run racing with startup or shutdown, you want to express dependencies, and basically just want a while loop with a sleep

writing a program that wants to set up (or remove, or change) a crontab entry for a user is quite fraught with racy danger, so from that perspective I think systemd wins as well

but on the other hand systemd interprets $SYSTEMD_EDITOR by slicing on whitespace rather than running via sh -c, which I was surprised to discover. that’s weird, right?

Saukkis
May 16, 2003

Unless I'm on the inside curve pointing straight at oncoming traffic the high beams stay on and I laugh at your puny protest flashes.
I am Most Important Man. Most Important Man in the World.
To what documentation are you comparing systemd? Because in my experience the documentation is better than most things in Linux. Sure, the division to multiple man pages is a chore and it is an annoyance trying to figure if the needed info is in the service or unit man page, but the information is there and in a logical place.

It's much better option than a single mega-man. I curse the bash man every time I have to search it for the syntax of history-command. And at least all the man pages are named systemd-something. I'm looking at you OpenSSL and 'man pkcs7'.

This week I come across a server that for some reason had a wrong stanza for enabling SSL in the Nginx config. So let's start with 'apropos nginx'. Okay, there is only nginx man and reading it, it is surprisingly short and doesn't have a single mention of "ssl".

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Klyith posted:

Though I've heard that cron can do times that systemd can't, if you want some real phase-of-the-moon poo poo.

if systemd authors weren’t cowards they would support all recurrences and exceptions from RFCs 5545 and 7529

VictualSquid
Feb 29, 2012

Gently enveloping the target with indiscriminate love.

Subjunctive posted:

ah, I thought systemd-cron was part of the core systemd stuff, but I guess not. an LSP (Language Server Protocol [service]) is a program that tells an editor or similar tool how to work with a given source language: syntax highlighting, autocomplete, refactorings, etc. there are some for systemd to help if you aren’t familiar with it

I used to use systemd-cron for some time, but it sucks.
For me it randomly stopped executing half of the cron.whatever directories after an update. And because it dynamically creates the unit files and refuses to generate anything resembling error messages, I couldn't fix it and went back to fcron.

And those tools sound like the thing that make systemd easier to use for actual developers, but are an additional hurdle for casual tinkerers which was my original statement.

Klyith posted:

"write a config from scratch" makes it sound really hard when all you are doing is copy-pasting ~13 lines of text, if you are making something with the same level of capability as cron.
That's it!

Yes. If you are familiar enough with the documentation/community to find something to copy from, then copying 2 files is barely more work then copying one line of code from the similar location for cron.
If you are not familiar with that then looking up a template or looking up the format for calendar can take a long time.

Armauk
Jun 23, 2021



Who is this guy?

DerekSmartymans
Feb 14, 2005

The
Copacetic
Ascetic

Armauk posted:

Who is this guy?

Gandalf Gygax

mawarannahr
May 21, 2019

i started out on FreeBSD and i still don't really know where to look for logs. I know journalctl -xe and dmesg. Not a fan. just let me grep

Tiny Timbs
Sep 6, 2008

I read systemd stuff for like two hours the other night and I still have no clue how to make a service run last and why rc.local is evil now

pseudorandom name
May 6, 2007

What does "make a service run last" mean?

edit: ok, I don't feel like doing socratic questioning. Units continuously become active and inactive in reaction to changing circumstances over the lifetime of the system. The "last" unit runs immediately before the syscall telling the computer to power off is made. You're going to have to explain your problem better because you're deep in XY territory.

pseudorandom name fucked around with this message at 01:18 on May 20, 2024

xzzy
Mar 5, 2009

systemd was designed so that you don't try to sequence startups, you set dependencies. This lets things sort themselves out and (in theory) boot faster.

If you really absolutely need a unit to run after every other startup service, you make a new target (analogous to run levels, but not really) like "myawesome.target" and have it depend on multi-user.target. Then you make your service depend on your new target and set it as the default with "systemd set-default".

Tiny Timbs
Sep 6, 2008

pseudorandom name posted:

What does "make a service run last" mean?

edit: ok, I don't feel like doing socratic questioning. Units continuously become active and inactive in reaction to changing circumstances over the lifetime of the system. The "last" unit runs immediately before the syscall telling the computer to power off is made. You're going to have to explain your problem better because you're deep in XY territory.

what

xzzy posted:

systemd was designed so that you don't try to sequence startups, you set dependencies. This lets things sort themselves out and (in theory) boot faster.

If you really absolutely need a unit to run after every other startup service, you make a new target (analogous to run levels, but not really) like "myawesome.target" and have it depend on multi-user.target. Then you make your service depend on your new target and set it as the default with "systemd set-default".

Yeah I saw some instructions like you described but the combination of making a new target and setting a system-level default just to run my lovely shell script gave me some "this can't really be the way you do this, right?" vibes. I did figure out a good dependency to use after some trial and error so I suppose I ended up doing the right thing anyway. It still seems to me that "run as root right before login" ought to exist in a simple way.

BattleMaster
Aug 14, 2000

I'm not a systemd expert but I thought that setting multi-user.target as a dependency was pretty equivalent to saying "do this after everything"

Nitrousoxide
May 30, 2011

do not buy a oneplus phone



The main confusing thing with Systemd in my experience is the difference between after= (assuming no other conditions will try to start up as soon as that target is present), requires= (needs that service/target to exist before it will start up and will fail the service if it isn't present when trying to start, will also try to start it if it's not present), wants= (will try to start up that service if it isn't present, but won't fail the service if it's not there, or it failed to start).

Before= defines order but doesn't create a hidden dependency on the referenced service. There's no failure condition like with Requires=

These three are more or less interchangeable in English and common parlance.

Nitrousoxide fucked around with this message at 01:32 on May 20, 2024

xzzy
Mar 5, 2009

Tiny Timbs posted:

setting a system-level default just to run my lovely shell script gave me some "this can't really be the way you do this, right?" vibes.

It's definitely not best practice, the expectation is to find what the actual requirement is and set that as a dependency. You can also set multiple if you want. But if you want to do it, the option is also there.

Sometimes finding the right dependency is a giant chore but that's just because there are a zillion services to sift through.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Nitrousoxide posted:

These three are more or less interchangeable in English and common parlance.

That is a…bold statement about the words “after”, “requires”, and “wants”, I have to say.

pseudorandom name
May 6, 2007

Subjunctive posted:

That is a…bold statement about the words “after”, “requires”, and “wants”, I have to say.

I've been confused about the claims that systemd has bad documentation and now I'm wondering about literacy rates.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

systemd has good reference documentation, but bad tutorial documentation (at least built in; there are a thousand medium articles about how to make a unit that does X)

Nitrousoxide
May 30, 2011

do not buy a oneplus phone



Subjunctive posted:

systemd has good reference documentation, but bad tutorial documentation (at least built in; there are a thousand medium articles about how to make a unit that does X)

I've found that Gemini has gotten a lot better at giving some examples for how to do systemd unit files lately.

Tiny Timbs
Sep 6, 2008

Nitrousoxide posted:

I've found that Gemini has gotten a lot better at giving some examples for how to do systemd unit files lately.

Interesting. I found ChatGPT pretty bad at it last time I tried to use it for something like this.

Truga
May 4, 2014
Lipstick Apathy
jesus christ

please do not use glorified markov chain bots to configure your system lmfao

Nitrousoxide
May 30, 2011

do not buy a oneplus phone



Truga posted:

jesus christ

please do not use glorified markov chain bots to configure your system lmfao

I didn't recommend just plugging in whatever an LLM suggests though? I said it's gotten better at giving examples.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

LLMs are basically designed and implemented to be good at converting something from one syntax to another. that’s their sweet spot. its a good use of them but yes obviously understand what something does before you apply it to your system

Adbot
ADBOT LOVES YOU

xzzy
Mar 5, 2009

Now that reddit sold their comment database to llm training let's start putting ExecStart=rm -rf / in every post over there and describe it as a systemd unit to remove viruses really fast.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply