linux_wiki:systemd_service_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux_wiki:systemd_service_script [2016/01/31 00:47]
billdozor [Implementation]
linux_wiki:systemd_service_script [2019/05/25 23:50]
Line 1: Line 1:
-====== Systemd Service Script ====== 
  
-**General Information** 
- 
-Creating a systemd until file (service script).  
- 
-**Checklist** 
-  * Enterprise Linux 7 
- 
----- 
- 
-====== Unit File Reference ====== 
- 
-  * /usr/lib/systemd/system => system unit configuration files (default with system) 
-  * /etc/systemd/system => additional configuration files (downloaded or custom) 
- 
----- 
- 
-====== Implementation ====== 
- 
-  * Download the code 
-  * Modify each section to make sense for your service 
-  * Copy to /etc/systemd/system/<name-of-service>.service 
-  * Start your service<code bash>systemctl start <name-of-service></code> 
- 
----- 
- 
-====== The Service Unit File ====== 
- 
-<code bash myprog.service> 
-[Unit] 
-Description=My Awesome Program 
-After=syslog.target 
- 
-[Service] 
-EnvironmentFile=/etc/myprog.d/config 
-ExecStart=/usr/local/bin/myprog.sh 
-Restart=on-abort 
- 
-[Install] 
-WantedBy=multi-user.target 
-</code> 
-  * Description => Displays near the top of output on "systemctl status myprog.service" 
-  * After => can be any valid ".target" unit 
-    * See all: systemctl -t target --all 
-  * EnvironmentFile => Configuration file to load 
-  * ExecStart => Executable to start 
-  * Restart => Auto restarts the program if an un-handled exit error occurs 
-  * WantedBy => If enabled, start under which target 
- 
-===== Example: Test Script ===== 
- 
-This is the script that was used to test the custom systemd service unit file. 
- 
-/usr/local/bin/myprog.sh 
-<code bash> 
-#!/bin/bash 
- 
-echo "Welcome to my program" 
-logger -p info "$0 has started on $(date)" 
- 
-while true; do 
-  logger -p info "$0 is still running..." 
-  sleep 30 
-done 
-</code> 
  • linux_wiki/systemd_service_script.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)