Created
January 19, 2022 03:08
-
-
Save pexcn/2e837dea915cb54d4d08f9884250d8c2 to your computer and use it in GitHub Desktop.
Run script monthly on systemd.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cat << EOF > /etc/systemd/system/monthly.timer | |
[Unit] | |
Description=Run script monthly | |
[Timer] | |
OnCalendar=*-*-01 02:00:00 | |
[Install] | |
WantedBy=timers.target | |
EOF | |
cat << EOF > /etc/systemd/system/monthly.service | |
[Unit] | |
Description=Run script monthly | |
Requires=docker.service | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/local/bin/monthly.sh | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat << EOF > /usr/local/bin/monthly.sh | |
#!/bin/sh | |
docker restart ssserver-websocket | |
docker restart ssserver-grpc | |
docker restart trojan-server | |
EOF | |
chmod +x /usr/local/bin/monthly.sh | |
systemctl enable monthly.timer --now | |
systemctl list-timers --all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment