3 Basic Commands and Simple Shell Scripts Once you have your first Red Hat Enterprise Linux rhel


#ls -l /usr/lib/systemd/system/*.target



Download 1.85 Mb.
View original pdf
Page39/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   35   36   37   38   39   40   41   42   ...   67
Pablo Iranzo Gómez, Pedro Ibáñez Requena, Miguel Pérez Colino, Scott McCarty - Red Hat Enterprise Linux 9 Administration-Packt Publishing (2022) -chap 3 82 - 180
#ls -l /usr/lib/systemd/system/*.target
Or, more correctly, we can use systemctl, like so:
#systemctl list-unit-files *.target
When you examine the output on your system, you will find some compatibility aliases for runlevels
0 to 6 that provide compatibility with the traditional ones.
For example, for regular server usage, the default target will be multi-user.target when you’re running without graphical mode or graphical.target when you’re using it.
We can define, as instructed in the placeholder at /etc/inittab, the new runlevel to use by executing the following command:
#systemctl set-default TARGET.target
We can verify the active one by using the following command:
#systemctl get-default
This brings us to the next question What does a target definition look like Let’s examine the output in the following screenshot:
Figure 4.4 – Contents of runlevel 5 from its target unit definition

Scheduling tasks with cron and systemd
113
As you can see, it is set as a dependency of another target (multi-user.target) and has some requirements on other services, such as display-manager.service, and also other conflicts, and the target can only be reached when other targets have completed.
In this way, systemd can select the proper order of services to start and the dependencies to reach the configured boot target.
Just in case, we can switch to anew runlevel with systemctl isolate targetname.target.
With that, we have covered the service’s status, as well as how to start, stop, and enable it on boot, but there are other tasks we should execute in our system, but in a periodic way. Let’s get further into this topic.
Scheduling tasks with cron and systemd
The skills you will learn in this section will be concerned with scheduling periodic tasks in the system for business services and maintenance.
For regular system usage, there are tasks that need to be executed periodically, ranging from temporary folder cleanup, updating the cache’s refresh rate, and performing check-in with inventory systems, among other things.
The traditional way to set them up is via cron, which is provided in RHEL 9 via the cronie package.
cronie implements a daemon that’s compatible with the traditional Vixie cron and allows us to define both user and system crontabs.
A crontab defines several parameters fora task that must be executed. Let’s see how it works.

Download 1.85 Mb.

Share with your friends:
1   ...   35   36   37   38   39   40   41   42   ...   67




The database is protected by copyright ©ininet.org 2024
send message

    Main page