systemctl自定义service执行shell脚本时报错code exited status 203 EXEC

您所在的位置:网站首页 shell脚本执行报错127 systemctl自定义service执行shell脚本时报错code exited status 203 EXEC

systemctl自定义service执行shell脚本时报错code exited status 203 EXEC

2024-07-06 03:26| 来源: 网络整理| 查看: 265

过程:

写了一个自定义systemctl的service,很简单,就是执行一个脚本去配置IP。

/etc/systemd/system/configip.service

[Unit] Description=configip service [Service] ExecStart=/home/root/configip.sh ExecReload=/home/root/configip.sh ExecStop= StandardOutput=tty [Install] WantedBy=multi-user.target

/home/root/configip.sh

ifconfig eth0 192.168.2.10 echo "ifconfig eth0 192.168.2.10"

可是执行的时候不起作用,使用status查看

systemctl status configip

发现报错,错误码203:

configip.service - configip service Loaded: loaded (/etc/systemd/system/configip.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2018-01-01 00:02:50 HKT; 6s ago Process: 649 ExecStart=/home/root/configip.sh (code=exited, status=203/EXEC) Main PID: 649 (code=exited, status=203/EXEC) 原因:

systemctl执行脚本时需要知道脚本的解释器

解决方法:

在/home/root/configip.sh脚本的开头加上#!/bin/sh

#!/bin/sh ifconfig eth0 192.168.2.10 echo "ifconfig eth0 192.168.2.10"

问题解决!



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3