crondの後継
https://rcmdnk.com/blog/2020/10/12/computer-raspberrypi-linux/
serviceファイルとtimerファイルを作成する
[Unit] Description = My Job [Service] Type = oneshot ExecStart = /path/to/myjob [Install] WantedBy = multi-user.target
[Unit] Description = My Job Timer [Timer] OnCalendar =Sun *-*-* 15:06:00 AccuracySec = 1s [Install] WantedBy = timers.target
記述ミスがあるとreloadでは反映されずrestartが必要。
sudo systemctl daemon-reload sudo systemctl enable myjob.timer sudo systemctl start myjob.timer
一覧表示 | nmcli d | |
dns 追加 | nmcli connection modify eno16780032 ipv4.dns 192.168.11.1 | |
NW再起動 | systemctl restart NetworkManager |
SSHD | systemctl restart sshd.service |
httpd | systemctl restart httpd.service |
postgres | systemctl start postgresql.service |
systemctl status httpd |
有効 | systemctl enable sshd.service |
無効 | systemctl disable sshd.service |
systemctl list-units --type=service
systemctl list-unit-files --type=service
firewall-cmd --permanent --add-port=任意のポート/tcp
firewall-cmd --list-all
[Unit] Description=%i managed by docker-compose Requires=docker.service After=docker.service
[Service] Type=simple Environment=COMPOSE_FILE=/root/infra/docker/%i/docker-compose.yml ExecStartPre=-/usr/bin/docker-compose -f ${COMPOSE_FILE} down --volumes ExecStart=/usr/bin/docker-compose -f ${COMPOSE_FILE} up ExecStop=/usr/bin/docker-compose -f ${COMPOSE_FILE} down --volumes [Install] WantedBy=multi-user.target
sudo systemctl enable --now docker-compose-service@mariadb