Live data from Hacker News

Systemd.timer, an Alternative to Cron

andrewpillar.com

151–155 of 155 posts

Re: Systemd.timer, an Alternative to Cron

#151
post #41

Earlier quoted context omitted.

Binary log files is another example of something that could have advantages in theory but never seems to work well in practice. What used to be "tail /var/log/nginx.log" is now man journalctl journalctl -u nginx journalctl | grep nginx go back to man page to look for more options to search etc

Your gripes all seem to boil down to your unfamiliarity, rather than anything specific that stands on its own as a problem. Unfamiliarity is understandable, but if that were enough to avoid progress, we wouldn't never have progress. > ctrl+C because it's taking too long Try --since=today. Then you end up in less, and that should be more familiar, including for search. This is then the equivalent of traditional daily…

As other commenters have mentioned, the unfamiliarity is a symptom of the time I spend using less,grep,sed,sort.. etc on a daily basis. If I could use those journalctl flags for everything I do relating to files on the system then I would be very familiar with them.

It's the same rule I use when purchasing kitchen equipment - often it's better to have a single multi-purpose tool than a bunch of specific implements. Otherwise you end up with a drawer full of strawberry-stem removers, pizza slicers, corn-cob peelers, avocado-slicers, etc.

This is to say nothing of the binary format issues that others have discussed.

Re: Systemd.timer, an Alternative to Cron

#152

https://htmx.org/essays/locality-of-behaviour/ Locality of behavior is important. Note how this systemd-thingy is split into two separate files? It's like that a lot in systemd, whoever is doing the architecture doesn'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't glance at a…

NixOS fortunately solves this problem. Here's a daily rsync with some names changed to protect any innocent hosts on my network. Note that the contents of "sync.sh" could easily go in there as well, but I was previously running it via cron, so didn't bother to move that over.

  systemd.services.somehost-sync = {
    startAt = "daily";
    path = [ pkgs.coreutils pkgs.rsync pkgs.openssh ];
    environment = {
      HOME = "/home/someuser";
    };
    script = ''/external/media/sync.sh'';
    serviceConfig.User = "someuser";
  };
Not everything in NixOS has been a "win" but systemd timers are so much more ergonomic under nix

Re: Systemd.timer, an Alternative to Cron

#153
post #148

Earlier quoted context omitted.

Yes, a for-profit corporation has the nefarious plan to... checks notes ...try to earn more revenues. We certainly can't stand for that!

Heh, well making your product worse for more revenue seems pretty warped, and increases the risk of lost market share. Even more warped is having 2 of your engineers join the Debian technical committee and use the bylaws to force a vote before anyone figures out exactly what SystemD is.

Were they coerced to vote for it? Why did they vote for it if they didn't know what it is? Honestly it's hilarious how systemd haters see conspiracies everywhere.

Re: Systemd.timer, an Alternative to Cron

#155

Earlier quoted context omitted.

Add the check at the start of the script?

What check exactly? What's the command?

Try this, replace "/foo/bar" with the path to your mount point, and the echos with additional desired behaviour.

(I'm assuming you're writing a bash script on a Linux system)

if grep -qs '/foo/bar' /proc/mounts; then

    echo "/foo/bar mounted"
else

    echo "/foo/bar not mounted"

    return 1 || exit 1
fi

Put these commands below the shebang but before the start of the script. I hope this helps you!

Edit: I added a crapload of newlines to better show the indentation and newlines required for the script to work. Sorry it's ugly

Post reply on HN