I have created a service on an Ubuntu 16.04 in order to run a c++ app after every boot.The c++ app runs among others ping measurements ,and that's why I need to start it after the network is up and to have cap\_net\_raw=ep. The service unit file I created and stored it under /etc/systemd/system/ is the following (app.service):

```
[Unit]
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
Restart=always
ExecStart=/home/app/script.sh

[Install]
WantedBy=default.target

```

The script.sh contains the following:

```
#!/bin/bash
sudo setcap cap_net_raw=ep /home/app/C++_APP  
cd /home/app
gnome-terminal -e "./C++_APP"

```

I have also given the following commands:

```
   chmod +x /home/app/script.sh    
   chmod 664 /etc/systemd/system/app.service
   systemctl daemon-reload
   systemctl enable app.service

```

However when I reboot the os the c++ app is not run and when I give:

```
systemctl status app.service

```

I get the following message :

```
app.service    Loaded: loaded (/etc/systemd/system/app.service; enabled; vendor preset: enabled)    Active: inactive (dead) (Result: exit-code) since Mon 2017-04-03 16:14:21 EEST; 2min 24s ago   Process: 2937 ExecStart=/home/user/script.sh (code=exited, status=1/FAILURE)

```

When I run the script manually it works fine. Has anyone any idea of what I have done wrong?