Systemd On Linux, Maintainence Details
linux
service
system manage
systemd
This article provides instructions for managing systemd services and viewing logs on Linux. It includes sample configuration files for various applications such as frpc, pyjom_webdav_rclone, clash_fastgithub, tujia_scraper_qq_bot, tempthrottle, and sync_git_repos_syncdog.
view full logs
journalctl -u <serviceName>.service
create, install, restart, reload
cd /etc/systemd/system
create <serviceName>.service
systemctl enable <serviceName>.service
systemctl daemon-reload
systemctl start <serviceName>.service
sample systemd service config files
maybe we should add some autorestart configs at it?
frpc_service.service
[Unit]=frpc service, expose ssh, webdav and code-server ports
Description=network.target
Wants=syslog.target network-online.target
After
[Service]=simple
Type=root
User=/root/frp_client_linux/frp_0.36.2_linux_amd64/frpc -c frpc.ini
ExecStart=/root/frp_client_linux/frp_0.36.2_linux_amd64
WorkingDirectoryRestart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
pyjom_webdav_rclone_service.service
[Unit]=rclone webdav served on pyjom, after the disk is mounted
Description
[Service]=root
User=/usr/bin/python3 mount_help_and_serve_pyjom.py
ExecStartWorkingDirectory=/root/Desktop/works/restore_sessions
[Install]
WantedBy=multi-user.target
tempthrottle.service
[Unit]=temperature control, cpu temperature under 60 celsius
Description
[Service]=root
User=/usr/bin/python3 tempthrottle_daemon.py
ExecStartWorkingDirectory=/root/Desktop/works/restore_sessions
[Install]
WantedBy=multi-user.target
clash_fastgithub.service
[Unit]=Clash Fastgithub Proxy
Description=network.target
After
[Service]=simple
Type=always
Restart=/usr/bin/clash -d /etc/clash
ExecStart[Install]
WantedBy=multi-user.target
tujia_scraper_qq_bot.service
[Unit]=two crucial services: tujia scraper, qq bot
Description=network.target
Wants=syslog.target network-online.target
After
[Service]="DISPLAY=:1"
Environment="XAUTHORITY=/root/.Xauthority"
Environment=root
User=/usr/bin/python3 main_daemon.py
ExecStartWorkingDirectory=/root/Desktop/works/restore_sessions
[Install]
WantedBy=graphical.target
sync_git_repos_syncdog.service
[Unit]=syncdog (server), to sync things to the cloud (github)
Description=sshd.service
Wants=network.target
Wants
[Service]=root
User=/usr/bin/python3 syncdog_test.py
ExecStartWorkingDirectory=/root/Desktop/works/sync_git_repos
[Install]
WantedBy=multi-user.target