美文网首页
ubuntu 开机启动脚本

ubuntu 开机启动脚本

作者: 雨田Ame | 来源:发表于2019-05-27 21:58 被阅读0次

vim /etc/systemd/system/frpc.service

```

[Unit]

Description=FRP Client Service

[Service]

ExecStart=/bin/bash /usr/local/frp/frpc_run.sh

[Install]

WantedBy=multi-user-target

```

In the .service file, I needed to add /bin/bash before the path to the script.

For example, for backup.service:

ExecStart=/bin/bash /home/user/.scripts/backup.sh

As opposed to:

ExecStart=/home/user/.scripts/backup.sh

```

sudo systemctl enable frpc

sudo service frpc start

```

```

sudo systemctl daemon-reload

```

```

$ sudo systemctl list-units |grep frpc

```

Python daemon and systemd service

```

#! /usr/bin/python3

```

chmod 777 xxx.py

```

[Unit]

Description=Auto Connect Wifi service

#Require=network.target

#After=syslog.target network.target remote-fs.target nss-lookup.target

#After=network.target

Conflicts=getty@tty1.service

After=multi-user.target

[Service]

Type=simple

User=root

Group=root

WorkingDirectory=/home/lab001/workspace/startup-script/auto_connect/

#ExecStart=/home/lab001/workspace/startup-script/auto_connect/auto_connect.py

ExecStart=/usr/bin/python3 /home/lab001/workspace/startup-script/auto_connect/auto_connect.py

#ExecStart=/home/lab001/workspace/startup-script/auto_connect/auto_connect.sh

StandardInput=tty-force

StandardOutput=syslog

StandardError=syslog

#RestartSec=30

#Restart=on-failure

#Restart=on-abort

[Install]

WantedBy=multi-user.target

~                         

```

```

$ sudo systemctl daemon-reload && sudo systemctl restart auto_connect.service && sudo systemctl status auto_connect.service

```

Problem:

Failed to execute operation: Invalid argument

https://askubuntu.com/questions/814/how-to-run-scripts-on-start-up

https://haoyu.love/blog521.html

https://stackoverflow.com/questions/45776003/fixing-a-systemd-service-203-exec-failure-no-such-file-or-directory

树莓派设置frpc开机启动

Automatically start long-running script on boot and keep it running with systemd

How do I figure out why systemctl service “systemd-modules-load” fails?

https://superuser.com/questions/997938/how-do-i-figure-out-why-systemctl-service-systemd-modules-load-fails

Systemd service not executing my Python script

Python daemon and systemd service

相关文章

网友评论

      本文标题:ubuntu 开机启动脚本

      本文链接:https://www.haomeiwen.com/subject/vzmbgqtx.html