树莓vnc添加启动start Job for vncserver.service failed because the control process exited with error code.

pi@raspberrypi:~ $ sudo service vncserver start 
Job for vncserver.service failed because the control process exited with error code.
See "systemctl status vncserver.service" and "journalctl -xe" for details.
pi@raspberrypi:~ $ vncserver

New 'X' desktop is raspberrypi:1

Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log

pi@raspberrypi:~ $ which vncserver
/usr/bin/vncserver
pi@raspberrypi:~ $ sudo vi /etc/init.d/vncserver
pi@raspberrypi:~ $ systemctl status vncserver.service
● vncserver.service - LSB: Start/stop vncserver
   Loaded: loaded (/etc/init.d/vncserver; generated; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-03-07 22:26:36 CST; 6min ag
     Docs: man:systemd-sysv-generator(8)
  Process: 946 ExecStart=/etc/init.d/vncserver start (code=exited, status=203/EX

3月 07 22:26:36 raspberrypi systemd[1]: Starting LSB: Start/stop vncserver...
3月 07 22:26:36 raspberrypi systemd[1]: vncserver.service: Control process exited
3月 07 22:26:36 raspberrypi systemd[1]: Failed to start LSB: Start/stop vncserver
3月 07 22:26:36 raspberrypi systemd[1]: vncserver.service: Unit entered failed st
3月 07 22:26:36 raspberrypi systemd[1]: vncserver.service: Failed with result 'ex

I think I found the answer:

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

I’m not sure why. Perhaps fish. On the other hand, I have another script running for my email, and the service file seems to run fine without /bin/bash. It does use default.target instead multi-user.target, though.

Most of the tutorials I came across don’t prepend /bin/bash, but I then saw this SO answer which had it, and figured it was worth a try.

The service file executes the script, and the timer is listed in systemctl --user list-timers, so hopefully this will work.

Update: I can confirm that everything is working now.

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

扫描二维码关注公众号,回复: 5660415 查看本文章

猜你喜欢

转载自blog.csdn.net/way1001/article/details/88323762