Bash Systemd服务失败,状态为203/EXEC,尽管shebang在sh文件中
我有一个简短的bash脚本,我想在我的Raspberry Pi启动时自动启动它。使用systemd,我一直试图手动测试服务文件,但它总是进入失败状态,不确定我做错了什么 我在谷歌上搜索过,大多数人说他们通过添加Bash Systemd服务失败,状态为203/EXEC,尽管shebang在sh文件中,bash,raspberry-pi,systemd,Bash,Raspberry Pi,Systemd,我有一个简短的bash脚本,我想在我的Raspberry Pi启动时自动启动它。使用systemd,我一直试图手动测试服务文件,但它总是进入失败状态,不确定我做错了什么 我在谷歌上搜索过,大多数人说他们通过添加 #/bin/bash添加到其.sh文件的顶部,或将该路径添加到服务文件(即ExecStart=/bin/bash file_to_execute.service)。我已经尝试了这两种方法,但仍然会遇到错误 这是我的.sh文件,我已经确认在手动运行时它可以工作: #!/bin/bash
#/bin/bash
添加到其.sh文件的顶部,或将该路径添加到服务文件(即ExecStart=/bin/bash file_to_execute.service
)。我已经尝试了这两种方法,但仍然会遇到错误
这是我的.sh文件,我已经确认在手动运行时它可以工作:
#!/bin/bash
sudo mining/2pac/cgminer/cgminer --default-config mining/2pac/cgminer/cgminer.conf &
sudo python3 mining/2pac/cgminer/BTCLotto-master/btclotto.py
以下是服务文件:
[Unit]
Description=BTC Lotto Miner
After=network.target network-online.target
Wants=network-online.target
[Service]
ExecStart=/mining/2pac/cgminer/lottominer.sh
[Install]
WantedBy=multi-user.target
对于这些文件,这些是我使用sudo systemctl start lottominer运行服务时遇到的错误。服务
:
lottominer.service - BTC Lotto Miner
Loaded: loaded (/lib/systemd/system/lottominer.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-07-24 16:47:05 UTC; 2s ago
Process: 2324 ExecStart=/mining/2pac/cgminer/lottominer.sh (code=exited, status=203/EXEC)
Main PID: 2324 (code=exited, status=203/EXEC)
Jul 24 16:47:05 raspberrypi systemd[1]: Started BTC Lotto Miner.
Jul 24 16:47:05 raspberrypi systemd[1]: lottominer.service: Main process exited, code=exited, status=203/EXEC
Jul 24 16:47:05 raspberrypi systemd[1]: lottominer.service: Unit entered failed state.
Jul 24 16:47:05 raspberrypi systemd[1]: lottominer.service: Failed with result 'exit-code'.
当我将服务文件编辑为ExecStart=/bin/bash/mining/2pac/cgminer/lottominer.sh
并在.sh文件中维护shebang时,我会收到相同的错误,但错误更改为(code=exited,status=127)
感谢您的帮助,我已经阅读论坛很长时间了,没有答案…使用绝对路径,没有相对路径,如
mining/2pac/cgminer/cgminer
。使用绝对路径,没有相对路径,如mining/2pac/cgminer/cgminer
。