Skip to content

miseon119/systemctl-service-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

systemctl-service-sample

A service sample file

This Config file is a basic example on how to execute a script during a boot time and auto-restart program on systemd Linux

Usage

Step 1: Create foo.service in /etc/systemd/system

$ cd /etc/systemd/system
$ touch foo.service

Step 2: Modify your foo.service file

Description : Your app simple description.

ExecStart : Your app or shell script path.

Restart : Restart options

Restart settings/Exit causes always on-success on-failure on-abnormal on-abort on-watchdog
Clean exit code or signal * *
Unclean exit code * *
Unclean signal * * * *
Timeout * * *
Watchdog * * * *

RestartSec: Time to sleep before restarting a service.

StartLimitIntervalSec StartLimitBurst reference

  • If your app needs to display GUI window, you need to add Environment.
Environment="DISPLAY=:0"

You need to find your XAUTHORITY path. Just type echo $XAUTHORITY to check.

Environment="XAUTHORITY=/yourPath/Xauthority"

Step 3

$ sudo chmod 755 foo.service

Step 4

$ sudo systemctl  daemon-reload

Step 5: Enable Your App Service

$ sudo systemctl enable foo.service

Step 6: Start Your App Service

$ sudo systemctl start foo.service

Step 7: Check your service status

$ sudo systemctl status foo.service

service file parameter

network-online.target: is a target that actively waits until the nework is "up", where the definition of "up" is defined by the network management software. more

Run Docker As A Service

reference

parameter

About

A service sample file

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors