DWQA 问题分类: 问题centos做自启动服务时提示code=exited, status=203/EXEC
huangjunwei1983huangjunwei1983 用户 提问于 2周 以前

本人是菜鸟,尝试做自启动的service,但出现了code=exited, status=203/EXEC错误,详细如下:
1、创建/root/test.sh,只有一句命令,仅为测试一下。#!/bin/bash为网上介绍的做法,也试过#!/bin/sh,也不行。
#!/bin/bash
rm /root/abc
 
2、在/etc/systemd/system/下创建test.service,内容如下:
 
[Unit]
Description=test

[Service]
ExecStart=/root/test.sh

[Install]
WantedBy=multi-user.target
 
3、chmod 777 /root/test.sh
4、systemctl daemon-reload
5、systemctl start test.service
6、systemctl status test.service,显示一堆错误:
test.service - test
   Loaded: loaded (/usr/lib/systemd/system/test.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 一 2019-11-04 22:41:06 CST; 1min 55s ago
  Process: 8049 ExecStart=/root/test.sh (code=exited, status=203/EXEC)
 Main PID: 8049 (code=exited, status=203/EXEC)
11月 04 22:41:06 localhost.localdomain systemd[1]: Started test.
11月 04 22:41:06 localhost.localdomain systemd[1]: test.service: main process exited, cod...EC
11月 04 22:41:06 localhost.localdomain systemd[1]: Unit test.service entered failed state.
11月 04 22:41:06 localhost.localdomain systemd[1]: test.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
请问各位大侠,哪里出错了。