2

I have the following launcher.sh file:

cd /root/craig/mybot
tmux new-session -d -s mybot "'/usr/bin/python3.5' launcher.py --start --auto-restart"

I then have the following mybot.service file in /systemd/system:

[Unit]
After=network.target

[Service]
ExecStart=/root/craig/mybot/launcher.sh

[Install]
WantedBy=default.target

When I run /root/craig/mybot/launcher.sh it works perfectly fine, but when I reboot my server the service starts and it seems like launcher.sh is never started (because the bot never comes online). Why is this? The service is shown as enabled. I'm on centOS 7.

When I run systemctrl status mybot, I get:

May 25 03:48:56 vultr.guest systemd[1]: Starting mybot.service...
May 25 03:48:56 vultr.guest systemd[818]: Failed at step EXEC spawning /root/craig/mybot/launcher.sh: Exec format error
May 25 03:48:56 vultr.guest systemd[1]: mybot.service: control process exited, code=exited status=203
May 25 03:48:56 vultr.guest systemd[1]: Failed to start mybot.service.
May 25 03:48:56 vultr.guest systemd[1]: Unit mybot.service entered failed state.
May 25 03:48:56 vultr.guest systemd[1]: mybot.service failed.
Craig
  • 121

1 Answers1

4

I have the following launcher.sh file:

[…]

May 25 03:48:56 vultr.guest systemd[818]: Failed at step EXEC spawning /root/craig/mybot/launcher.sh: Exec format error

systemd is not a shell interpreter. It does not do what shells do, including falling back to interpreting programs themselves if they cannot execute them directly as program image files.

/root/craig/mybot/launcher.sh is not a valid executable that can be used as a program image file by the execve() system call. To be so, it needs to have the magic number denoted by the characters #! in the first two bytes of the file, followed by the pathname of the interpreter that will interpret the remainder of the file.

Further reading

muru
  • 72,889
JdeBP
  • 68,745