Replacing cron with systemd timer

Well, I don’t currently really have a good reason to replace a working cron job with systemd-timer beside practicing it. The following is the existing cron task for www-data user. I want to convert this cron to a systemd-timer: $ sudo crontab -l -u www-data # m h dom mon dow command */5 * * * * php -f /var/www/nextcloud/cron.php The above output indicates that the command php -f /var/www/nextcloud/cron.php is run at every 5th minute, of course by www-data user....

September 3, 2024 · 3 min · 428 words · kenno

Systemctl cat is cool

Sometimes we want to see the content of a Systemd unit file. One obvious way to do it is to just cat/vim the content of the unit file directly. For example, to display the content of systemd-tmpfiles-clean.timer, we can perform the following step: ➜ systemctl status systemd-tmpfiles-clean.timer | grep Loaded Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.timer; static) ➜ cat /usr/lib/systemd/system/systemd-tmpfiles-clean.timer; # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2....

July 20, 2024 · 2 min · 306 words · kenno

Mounting NFS share with Systemd Automount

On my main workstation running Fedora 36, I use both autofs and Systemd automount to mount NFS on demand. Gradually, I’m leaning toward just to use Systemd automount. Here is just a brain dump with an example of mounting an NFS share with Systemd autmount. Though, I had done this before, I found this blog post, available at [1], provides details on how to do this. Assumption The NFS server and share: banan....

June 13, 2022 · 2 min · 359 words · kenno

Clean Up Systemd Journal Logs

On my Fedora 33 system, the systemd journal is persistently logged. Over time, the size of the log accumulate quite a lot. # du -shx journal/ 4.2G journal/ I already cleaned up the log twice in the past, but I already forgot how to do it. To fix my short-term memory, I’m going to document how I do this by following this blog post Clear systemd journal. The command for cleaning up old logs is journalctl with the option --vaccume-time=OLDER_THAN_TIME....

March 26, 2021 · 1 min · 166 words · kenno

Systemd List Failed Units and Services

This is a quick note to list failed services on systemd system. [root@zilla ~]# systemctl status ● zilla State: degraded Jobs: 0 queued Failed: 1 units Since: Fri 2020-09-04 02:20:47 AEST; 3 months 11 days ago CGroup: / ├─1 /usr/lib/systemd/systemd --system --deserialize 22 └─system.slice ├─httpd.service │ ├─21860 /usr/sbin/httpd -DFOREGROUND │ ├─21861 /usr/sbin/httpd -DFOREGROUND │ ├─21862 /usr/sbin/httpd -DFOREGROUND │ ├─21863 /usr/sbin/httpd -DFOREGROUND │ ├─21864 /usr/sbin/httpd -DFOREGROUND │ └─21865 /usr/sbin/httpd -DFOREGROUND ... [root@zilla ~]# systemctl list-units --failed UNIT LOAD ACTIVE SUB DESCRIPTION ● ipmi....

December 15, 2020 · 2 min · 233 words · kenno

Cleaning Up Systemd Journal Logs

“Bad boys, whatcha want. Watcha want, whatcha gonna do when the root is full?” Actually, what are you gonna do when the journald taking up lots of space? For example, during the operating system upgrade on my desktop, the free space on / is not sufficient. Error Summary ------------- Disk Requirements: At least 5643MB more space needed on the / filesystem. So, I check how much space the systemd-journald log was consuming:...

October 10, 2020 · 1 min · 142 words · Kenno

How to Enable Persistent Logging for Systemd Journal

On RHEL 7/8, CentOS 7/8 and even Ubuntu (??), by default the journal log data is stored only in memory (/run/log/journal/ directory). There are 2 ways to retain the journal log messages. The first one is to set the variable Storage to persistent in the /etc/systemd/journald.conf. [Journal] Storage=persistent Then restart the systemd-journald service. Another solution is simpler and it looks like it’s the recommended way of achieving this. All we have to do is to create a directory, /var/log/journal (with correct ownership and permission), and journald will automatically store the log messages there....

August 29, 2020 · 2 min · 418 words · kenno

systemd - start, status, enable example

This is just a quick note to remind myself how to enable or disable services using Systemd. In this example, I’m using denyhosts service. Check if a service is running. # systemctl status denyhosts denyhosts.service - SSH log watcher Loaded: loaded (/usr/lib/systemd/system/denyhosts.service; disabled) Active: inactive (dead) Start a service and verify its running status: # systemctl start denyhosts # systemctl status denyhosts denyhosts.service - SSH log watcher Loaded: loaded (/usr/lib/systemd/system/denyhosts.service; disabled) Active: active (running) since Thu 2014-07-17 01:44:29 EDT; 1min 25s ago Process: 15722 ExecStart=/usr/bin/denyhosts....

July 17, 2014 · 1 min · 162 words · kenno