Search code examples
linuxsystemd

How to automatically execute shell script at startup boot on systemd Ubuntu 18.04


I want setup shadowsocks antumatically start at startup on ubuntu 18.04

See this.

My shell is shadowsocks.sh

#!/bin/bash
if [ -f /usr/bin/sslocal ]; then 
   sudo /usr/bin/sslocal -c /etc/shadowsocks/config.json -d restart -v
fi

It runs well

and I setup with systemctl

like this shadowsocks.service

[Service]
ExecStart=/usr/local/bin/shadowsocks.sh
[Install]
WantedBy=default.target
Alias=ss.service

when I run

sudo systemctl start ss.service

I can see shadowsocks logged "started"

but I can't see shadowsocks started and I can't use google.

I'm chinese, I'm sorry for my bad English, I wish someone can see my question


Solution

  • delete -d in shell script

    everything is ok