Thursday, 4 June 2015

Create Custom Unit File (to run a Custom Daemon) in systemd in RHEL7

In a previous post we configured Swatch Log Monitoring Tool. In this post we will configure swatch as a custom daemon in 'systemd' by creating a custom unit file in 'systemd' and loading it into 'systemd'.

Perform the following steps:

1) Create a unit file in /etc/systemd/system/ directory.
[root@meru ~]# touch /etc/systemd/system/swatch.service

[root@meru ~]# chmod 664 /etc/systemd/system/swatch.service

2) Edit the Unit File.
[root@meru ~]# vi /etc/systemd/system/swatch.service

Description=Swatch Log Monitoring Daemon auditd.service sshd.service

ExecStart=/bin/swatch --config-file=/etc/swatch/secure.conf --tail-file=/var/log/secure --pid-file=/var/run/ --daemon
ExecStop=kill -s KILL $(cat /var/run/


  • Description is an informative description that is displayed in journal log files and in the output of the systemctl status command. 
  • After setting ensures that the service is started only after the given space-separated list of services or targets are running.
  • ExecStart stands for the path to the actual service executable. 
  • Type=forking is used for daemons that make the fork system call. The main process of the service is created with the PID specified in PIDFile
  • WantedBy states the target or targets that the service should be started under. 

3) Notify systemd about the new swatch.service file.
[root@meru system]# systemctl daemon-reload

4) Start Swatch service
[root@meru system]# systemctl start swatch.service

You can now use all systemctl commands for swatch.service.

1 comment:

  1. Hi All!

    I'm selling fresh & genuine SSN Leads, with good connectivity. All data properly checked & verified.
    Headers in Leads:

    First Name | Last Name | SSN | Dob | Address | State | City | Zip | Phone Number | Account Number | Bank Name | DL Number | Routing Number | IP Address | Reference | Email | Rental/Owner |

    *You can ask for sample before any deal
    *Each lead will be cost $1
    *Premium Lead will be cost $5
    *If anyone wants in bulk I will negotiate
    *Sampling is just for serious buyers

    Hope for the long term deal
    For detailed information please contact me on:

    Whatsapp > +923172721122
    email >
    telegram > @leadsupplier
    ICQ > 752822040