-
Notifications
You must be signed in to change notification settings - Fork 0
/
SystemD
42 lines (30 loc) · 1.22 KB
/
SystemD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
## https://systemd.io/
## take the description with a grain of salt
Creating Systemd Services and Timers(Basic)
------------------------------------------
Systemd Service
- make your custom shell script/app available under command `systemctl`
<filename>.service
==================
[Unit]
Description=this value will be shown when using command `systemctl status <filename>.service`
[Service]
Type=oneshot
ExecStart=<path/to/shell/script>.sh
User=<user of the .sh file>
Group=<user of the .sh file>
Systemd Timer
- used in conjunction with Systemd Service, works like crontab that triggers/runs scripts based on the schedule
<filename>.timer
================
[Unit]
Description=this value will be shown when using command `systemctl status <filename>.timer`
[Timer]
OnCalendar=Mon..Fri 00:00:00 #refer to https://man.archlinux.org/man/systemd.time.7#CALENDAR_EVENTS
Unit=<filename>.service
[Install]
WantedBy=timers.target
** note
both of these file should be under <path/to/systemd/system/*> for it be readable
run `sudo systemctl daemon-reload` command to make the custom service and timer to be recognized by systemctl.
commands like systemctl start, stop, enable, disable, status, etc. should now be usable for the service and timer.