说个题外话,linux问题还是google靠谱
根据你的错误信息,搜systemctl status=203
第一条就是解决问题的方法和答案,和分析过程。
https://unix.stackexchange.com/questions/472950/systemd-status-203-exec-error-
when-creating-new-service
The error message (code=exited, status=203/EXEC) is often seen when the
script itself or its interpreter cannot be executed.
It could have these reasons:
wrong path to script (e.g. /home/py/ReadPressure2AndPostToMqtt.py)
script not executable
no shebang (first line)
wrong path in shebang (e.g. /bin/python3)
internal files in your script might be missing access permissions.
SELinux may be preventing execution of the ExecStart parameter; check
/var/log/audit/audit.log for messages of the form: type=AVC msg=audit([...]):
avc: denied { execute } or in the output of ausearch -ts recent -m avc -i.
You have the wrong WorkingDirectory parameter
【 在 optimism 的大作中提到: 】
: 标 题: 请教linux下建立服务的问题,头痛,求高人指教,谢谢
: 发信站: 水木社区 (Tue Oct 18 10:59:09 2022), 站内
:
:
: 服务器是亚马逊的Red Hat Enterprise Linux with High Availability,安装的东西
: 非常少。
: 想在上面建立一个服务,没成功。于是我试着建立一个最简单的服务。
:
: 在ec2-user的用户目录下建立了一个名为fakeservice.sh的脚本文件:
: #!/bin/sh
: echo "fake service started."
: sleep 90
: echo "after sleep"
:
: 在命令行可以正常执行。
:
: 进入/etc/systemd/system,sudo vi Myfakeservice.service:
: [Unit]
: Description= My fake service
: After=network.target network-online.target syslog.target
: Wants=network.target network-online.target
:
: [Service]
: User=ec2-user
: Type=simple
: ExecStart=/home/ec2-user/fakeservice.sh
: [Install]
: WantedBy=multi-user.target
:
: 保存退出, 然后sudo systemctl daemon-reload
: sudo systemctl start Myfakeservice
:
: sudo systemctl status Myfakeservice
:
: [ec2-user@ip-172-31-2-189 system]$ sudo systemctl status Myfakeservice
: ● Myfakeservice.service - My fake service
: Loaded: loaded (/etc/systemd/system/Myfakeservice.service; disabled;
: vendor preset: disabled)
: Active: failed (Result: exit-code) since Mon 2022-10-17 21:36:17 CST;
: 44s ago
: Process: 1530 ExecStart=/home/ec2-user/fakeservice.sh (code=exited,
: status=203/EXEC)
: Main PID: 1530 (code=exited, status=203/EXEC)
:
: Oct 17 21:36:17 ip-172-31-2-189.us-east-2.compute.internal systemd[1]:
: Started My fake service.
: Oct 17 21:36:17 ip-172-31-2-189.us-east-2.compute.internal systemd[1]:
: Myfakeservice.service: Main process exited, code=exited, status=203/EXEC
: Oct 17 21:36:17 ip-172-31-2-189.us-east-2.compute.internal systemd[1]:
: Myfakeservice.service: Failed with result 'exit-code'.
:
: 这个问题我怎么百度也解决不了。求高人指教。
: --
:
: ※ 来源:·水木社区
http://www.mysmth.net·[FROM: 123.119.235.*]
--
FROM 119.139.199.*