You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[update] Use systemd to Start a Linux Service at Boot (#7221)
* [update] Use systemd to Start a Linux Service at Boot
Incorporated the review comments
* Update index.md
formatting changes
* fix blueberry
* copy edits and update code block formatting
---------
Co-authored-by: jddocs <[email protected]>
For more information about the unit file and its available configuration options, see the [systemd documentation](https://www.freedesktop.org/wiki/Software/systemd/).
68
83
69
84
## Start and Enable the Service
70
85
71
86
1. Once you have a unit file, you are ready to test the service:
72
87
73
-
sudo systemctl start myservice
74
-
88
+
```command
89
+
sudo systemctl start myservice
90
+
```
75
91
76
92
2. Check the status of the service:
77
93
78
-
sudo systemctl status myservice
94
+
```command
95
+
sudo systemctl status myservice
96
+
```
79
97
80
98
If the service is running correctly, the output should resemble the following:
Active: active (running) since Wed 2018-05-02 15:03:07 UTC; 48s ago
146
+
Main PID: 2973 (bash)
147
+
CGroup: /system.slice/myservice.service
148
+
├─2973 /bin/bash /usr/bin/test_service.sh
149
+
└─3371 sleep 30
132
150
133
-
For more information about using `systemctl` commands, see the [systemctl guide](/docs/guides/introduction-to-systemctl).
151
+
May 02 15:03:07 localhost systemd[1]: Started Example systemd service..
152
+
May 02 15:03:07 localhost systemd[1]: Starting Example systemd service....
153
+
May 02 15:03:07 localhost bash[2973]: Looping...
154
+
May 02 15:03:37 localhost bash[2973]: Looping...
155
+
```
134
156
157
+
For more information about using `systemctl` commands, see the [systemctl guide](/docs/guides/introduction-to-systemctl).
135
158
136
159
## Troubleshooting
137
160
138
-
- "Example service started at ..." line does not appear in the output of the status command. The `systemd-cat` output is not reliable because of a race condition. As a workaround update the `test_service.sh` file as follows:
139
-
{{< file "test_service.sh" bash >}}
161
+
If the `Example service started at ...` line does not appear in the output of the status command, the `systemd-cat` output may not be reliable because of a race condition. As a workaround, you can update the `test_service.sh` file as follows:
0 commit comments