Hot answers tagged

10

One mistake you did was trying to start sshd by hand. If you instead start sshd through official means it should just work. The service command knows what the correct way to start a service on your distribution is, and this should work: service ssh start In case of sysv init scripts, that's everything you need to do. The reason the directory is missing is ...


9

One of the major difference is, After only checks if the unit is activated already, and does not explicitly activate the specified units. The units listed in Requires are activated together with the unit. If any of the required units fail to start, the unit is not activated. Consider I have a unit file test-app.service, [Unit] Description=test app After=...


9

So /run (and /var/run symlinked to it) gets recreated every reboot. Except that systemd-tmpfiles isn't doing that for some files including (/var)/run/sshd. Apparently, this is fixed by a OpenVZ kernel upgrade. But to actually fix it now you edit /usr/lib/tmpfiles.d/sshd.conf and remove /var from the line d /var/run/sshd 0755 root root to read instead: d /...


8

# timestamps corresponds to your current timezone user@node:~$ journalctl --list-boots -3 0f2fcb9569384a2aa2d5492505f86cda Tue 2018-11-27 16:45:22 CET—Thu 2018-11-29 10:10:07 CET -2 646787bd244d4230a5986f00207c1e8c Sun 2019-02-24 19:50:23 CET—Tue 2019-02-26 22:49:29 CET -1 c922041a9a3847babd51ac79dd06923c Wed 2019-02-27 08:27:28 CET—Sun 2019-03-03 08:52:52 ...


8

Apparently, /dev/log was missing, which is created by systemd-journald-dev-log.socket. I had to do systemctl restart systemd-journald.service to fix it. I can't reboot right now to test if this is permanent, but I'll take it for now.


6

To use an actual NTP implementation, you need to install and configure one, chrony or maybe ntpd. Do so if you require any monitoring of time performance. I will assume chrony. Add iburst to your pool or server lines in your config to speed up the initial few packets. It still may take a couple minutes to stabilize, be patient. chronyc tracking will show ...


5

It may be better to not configure system services to listen on specific IP addresses, and to control access to them via the host firewall if necessary. If you really need to be able to bind to specific IP addresses before they are configured on a network interface, you can work around the timing issue by setting the sysctl net.ipv4.ip_nonlocal_bind for IPv4 ...


5

Probably because you haven't told cron to use root. * * * * * root /bin/systemctl stop nginx That will execute the command every minute, regardless of the nginx status (started or not) So that being said, if the goal is to make sure nginx is never started, why not just disable it? systemctl disable nginx ==Edit== Good point made by Aaron Copley in the ...


5

Details of the naming scheme are in the source code: udev/udev-builtin-net_id.c. Some common schemes are PCI physical, PCI hotplug, and onboard. Your enp interface suggests physical. Stripping out exotic and irrelevant bits from the comments leaves these rules: * Two character prefixes based on the type of interface: * en — Ethernet * * Type of ...


4

This behaviour is reported on this Debian Bug, you only need to setup correctly the shutdown scripts shiped with the package because, automatically, they aren't copied by default: cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/ systemctl enable ssh-session-cleanup.service


4

Some years later and with systemd 232 it dosn't work anymore as described in the question and in the answers from 2016. Option name StartLimitIntervalSec and Sections have changed. Now it has to look like this example: [Unit] StartLimitBurst=5 StartLimitIntervalSec=33 [Service] Restart=always RestartSec=5 ExecStart=/bin/sleep 6 This will do 5 restarts in ...


4

Apparently this gets resolved when running an OpenVZ kernel 2.6.32-042stab134.7 or newer. I find it strange that there is no fix possible in the systemd start scripts somehow. Probably an ugly hack like automatically creating /run/sshd/ after starting up and then starting sshd would work. The output of my systemd-tmpfiles --create: [/usr/lib/tmpfiles.d/var....


4

You're not meant to edit the systemd service files shipped with packages. These can be replaced at any time, e.g. when the package is updated. Instead, you should create override files containing the changes you want to make. These will be preserved because they are not part of the system package which gets updated. The simple way to do this is to run ...


4

Without installing any more packages... Turn NTP off, manually set the time to be close enough, turn NTP back on: Set NTP Service inactive $ timedatectl set-ntp false Set the time manually Yeah, that's sad but it works and you don't need to muck around installing anything and make it work. Get the approximate LOCAL time from the wall clock, your phone, ...


4

systemd-tmpfiles is a systemd's feature that can be configured to clean old files from a directory automatically. Instead of a new service that requires startup every time a directory cleanup is needed, one could create a file under /etc/tmpfiles.d/ with the following content: # /etc/tmpfiles.d/cleanup_index_cache.conf d /path/to/dir - - - 7d References: ...


4

In the /etc/fstab entries for your mounts you can add systemd specific options, including the nofail option will instruct systemd that the boot can continue without waiting for the mount unit and regardless whether the mount point can be mounted successfully. You can add the options x-systemd.device-timeout and or x-systemd.mount-timeout to customize time-...


4

Try to create systemd file for nifi, below is example please change path/user/group accordingly. $ sudo vi /etc/systemd/system/nifi.service [Unit] Description=Apache NiFi After=network.target [Service] Type=forking User=nifi Group=nifi ExecStart=/opt/nifi-latest/bin/nifi.sh start ExecStop=/opt/nifi-latest/bin/nifi.sh stop ExecRestart=/opt/nifi-latest/bin/...


3

The best I found for check it in scripts (programmatically): loginctl show-user $USER --property=Linger 2>/dev/null | grep -q 'yes'


3

As I cannot add a comment due to lack of reputation, please take this as a comment to Michael Hampston's answer. When modifying the systemd service file, use the command systemctl edit redis-server to create an override. In the resulting edit window, type the following: [Service] Type=notify Save and exit then finish the installation apt install -f. If ...


3

Use [Unit] … After=cloud-final.service … [Install] WantedBy=cloud-init.target I ran into this as well. journalctl showed user data stuff running after multi-user and before the target cloud-init was reached. <timestamp> <ip_addr> systemd[1]: Reached target Multi-User System. [snip] <timestamp> <ip_addr> systemd[1]: Starting Execute ...


3

A systemd timer can be scheduled for an interval respective to system boot/start time with the OnActiveSec=, OnBootSec=, OnStartupSec=, OnUnitActiveSec= options /etc/systemd/system/your-notcron-hourly.timer [Unit] Description=Run Something every hour respective to systemd start time [Timer] OnUnitActiveSec=1h [Install] WantedBy=timers.target


3

just try setting timezone. # timedatectl set-timezone *your timezone*


3

First, your systemctl syntax is wrong: systemctl kill expects a unit name, not a PID, and -s requires a signal name. As written, it won't do anything but give you an error message: Failed to parse signal string kill. If you fix that, it will then tell you: Failed to kill unit 3645.service: Unit 3645.service not loaded. The correct syntax would be: ...


3

I've finally found it! It's of course but a simple kernel parameter, found here https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html The parameter I was specifically looking for is rootdelay, I had already tried rootwait but apparently that wasn't enough, as it still aborted the wait after 10 seconds. Now it actually does not wait the ...


3

The unit file you posted looks fine. But the unit as you defined it here has no strict dependencies, only weak (Wants= instead of Requires=). That means if network.target is not there or if it fails to start, this unit would be started anyway. After= (and Before=) is used only for ordering, not for dependency management. So if your app needs another service, ...


3

If you're using NetworkManager, then in order for network-online.target to work as expected, you need to enable service NetworkManager-wait-online.service, which is the one that actually waits for the network to be online to satisy that target. The network-online.target needs to be "hooked" into your network manager (since NetworkManager is not the only ...


3

This is a bug in systemd. I have filed a bug report and done analysis of what is wrong here: https://github.com/systemd/systemd/issues/11338 That issue manifests here as the target gains a Wants= on the unit that Requires= a masked unit. The transaction is built and systemd has already added a job for the anchor unit, its Wants= dependency, and does not ...


3

The logic of it is that Ubuntu has a built in DNS cache, which it checks first when trying to resolve anything. In this version, by default, NetworkManager is not updating /etc/resolv.conf instead it’s calling application called resolvconf. This approach: service resolvconf disable-updates update-rc.d resolvconf disable service resolvconf stop May not ...


3

In /etc/polkit-1/rules.d/10-myservice.rules polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.systemd1.manage-units" && subject.isInGroup("somegroup")) { if (action.lookup("unit") == "foo.service") { var verb = action.lookup("verb"); if (verb == "start" || verb == "stop" || verb == "...


3

You activate SystemD units permanently with enable: sudo systemctl enable reboot.timer Note: start only starts them one time, and enable don't start them right away (only at next boot). You can combine both with the --now option: sudo systemctl enable --now reboot.timer will permanently activate the unit and starts it immediately.


Only top voted, non community-wiki answers of a minimum length are eligible