Skip to content

Instantly share code, notes, and snippets.

@pexcn
Created January 19, 2022 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pexcn/2e837dea915cb54d4d08f9884250d8c2 to your computer and use it in GitHub Desktop.
Save pexcn/2e837dea915cb54d4d08f9884250d8c2 to your computer and use it in GitHub Desktop.
Run script monthly on systemd.
#!/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