how to redirect systemd logs in to the file

how to redirect systemd logs in to the file

Redirect systemd logs in file

Step 1:

Open service file and update following tags, in this tutorial we use tomcat service.

StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=tomcat

vi  /lib/systemd/system/tomcat.service

[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINE_BASE=/opt/tomcat
Environment='CATALINE_OPTS=-Xms128M -Xmx765M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.haedless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID

User=tomcat
Group=tomcat

StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=tomcat


[Install]
WantedBy=multi-user.target

Step 2:

Create file in rsyslog.d directory in any name

vi /etc/rsyslog.d/tomcat.conf

if $programname == 'tomcat' then /var/log/tomcat/file.log
& stop

Step 3:

Restart rsyslog and tomcat

systemctl  daemon-reloadsystemctl restart rsyslog tomcat

Step 4: 

Check log file
cat  /var/log/tomcat/file.log

Thanks,

Please share and like if this article is helpful 
 

Configure yum server in centos 7 | step by step yum repository | linux package manager

YUM (Yellowdog Updater Modified) is an open source package management tool for RPM (RedHat Package Manager) based Linux systems. It allows  to easily install, update, remove or search software packages on a systems.

OS        -    CentOS 7
IP        -    172.17.20.110
Package    -    Createrepo        

Step 1

Install Createrepo Package :

yum install createrepo httpd

yum server, yum repo server, yum repository server, update yum server, update yum server, update yum repository, update yum, createrepo, yum server tutorial


Step 2

Copy ISO file of CentOS 7 everything OR download from internet it’s approx 6-7GB.

Note : - In this tutorial we used a CentOS 7 64bit Minimal and copy in “iso” directory

ls  /iso


Create repo directory - select name according to your project

mkdir  /var/www/html/linuxtopic


Step 3

Mount CentOS 7 ISO

mount -o loop /iso/CentOS-7-x86_64-Minimal-1708.iso

yum server, yum repo server, yum repository server, update yum server, update yum server, update yum repository, update yum, createrepo, yum server tutorial

cd /mntls


Copy Packages in repo directory

rsync -av  /mnt/Packages/   /var/www/html/linuxtopic/


Step 4

Generate yum repository

createrepo /var/www/html/linuxtopic

yum server, yum repo server, yum repository server, update yum server, update yum server, update yum repository, update yum, createrepo, yum server tutorial

Your repo generated successfully , you can check repodata folder

ls -l /var/www/html/linuxtopic/repodata/


Restart  httpd server

systemctl restart httpdSystemctl status httpd


Step 5

Go to  Client and  Add repo entry in yum.repo.d, create any file add following entry

vi /etc/yum.repos.d/linuxtopic.repo

[linuxtopic]                  
name=linuxtopic yum repo      
baseurl=http://172.17.20.110/linuxtopic    


enabled=1          
gpgcheck=0

[linuxtopic]                        =    Repository name

baseurl=http://172.17.20.110/linuxtopic     =    base url of yum server

enabled=1                       =    1 = enable / 0= disable

gpgcheck=0                    =    0 = disable / 1 =  enable

Step 6

Install Package

yum clean expire-cache ; sudo yum --disablerepo="*" --enablerepo="linuxtopic" install  package-name
Ex
yum clean expire-cache ; sudo yum --disablerepo="*" --enablerepo="linuxtopic" install  chrony


Step 7

Update yum repository

Download / copy rpm package in  /var/www/html/linuxtopic directory

yum --downloadonly --downloaddir=/var/www/html/linuxtopic/ vim*


Update Repository

createrepo --update /var/www/html/linuxtopic



Thanks,

Please share, like and follow us

yum repo updating using bash script in CentOS 7 | yum server update


This is a bash script for update yum repository. This script will work if new RPM packages found in repository folder. There is no required to manual to update repository for new package. Just create script and set cron.