Failed at step exec spawning exec format error

I am writing a linux service to deploy my springboot web app as a service. Here is the service file springboot.service [Unit] Description=My Webapp Java REST Service [Service] User=ubuntu # The

I am writing a linux service to deploy my springboot web app as a service.
Here is the service file springboot.service

[Unit]
Description=My Webapp Java REST Service

[Service]
User=ubuntu
# The configuration file application.properties should be here:

#change this to your workspace
WorkingDirectory=/home/ubuntu

#path to executable. 
#executable is a bash script which calls jar file
ExecStart=/home/ubuntu/spring-start

SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

My script file spring-start.sh

sudo java -jar "/home/ubuntu/FirstWebAppWithoutDB.jar"

I also gave execution permission to the spring-start.sh by chmod u+x spring-start.sh

sudo systemctl daemon-reload

sudo systemctl enable springboot.service

sudo systemctl start springboot

sudo systemctl status springboot

Unfortunately the service fails with error Exec format error:

springboot.service: Failed to execute command: Exec format error
Jul 14 07:39:56 ip-172-31-40-71 systemd[10075]: springboot.service: Failed at step EXEC spawning /home/ubuntu/spring-start.sh: Exec format error

asked Jul 14, 2019 at 8:08

anwesh mohapatra's user avatar

anwesh mohapatraanwesh mohapatra

8034 gold badges11 silver badges18 bronze badges

1

add shebang to the script

#!/bin/bash
sudo java -jar "/home/ubuntu/FirstWebAppWithoutDB.jar"

and execution permission

chmod +x spring-start.sh

answered Jul 14, 2019 at 8:35

UtLox's user avatar

4

Your spring-start.sh is executed by bash you need to explicit your ExecStart in springboot.service file like this :
ExecStart=/bin/bash /home/ubuntu/spring-start.sh

answered Feb 16, 2021 at 22:54

Jamal IMEHLI's user avatar

2

Another answer for those searching! If you are calling a binary and not a script, make sure it’s built for the correct architecture (arm/x86) and that you can run it directly, which might show you the problem.

My binary was built for x86 and when I ran it on arm, the console error was unexpected ) but this caused the binary to error, which caused systemd to log Exec format error which was nothing to do with the format in the service file.

answered Dec 19, 2022 at 17:43

Luke Briner's user avatar

Luke BrinerLuke Briner

6884 silver badges21 bronze badges

ExecStart=/bin/bash … script.sh

answered Apr 1, 2022 at 20:25

IvanP's user avatar

1

Содержание

  1. Почему не работает созданная служба systemd?
  2. Arch Linux
  3. #1 2012-09-22 22:12:42
  4. [SOLVED]Starup sript not getting executed in systemd
  5. Arch Linux
  6. #1 2017-11-30 20:02:24
  7. [SOLVED] service: Failed to execute command: Exec format error
  8. #2 2017-11-30 20:06:42
  9. Re: [SOLVED] service: Failed to execute command: Exec format error
  10. #3 2017-11-30 20:22:08
  11. Re: [SOLVED] service: Failed to execute command: Exec format error
  12. #4 2017-11-30 21:23:30
  13. Re: [SOLVED] service: Failed to execute command: Exec format error
  14. #5 2017-11-30 22:05:37
  15. Re: [SOLVED] service: Failed to execute command: Exec format error
  16. #6 2017-11-30 22:35:50
  17. Re: [SOLVED] service: Failed to execute command: Exec format error
  18. #7 2017-11-30 23:26:28
  19. Re: [SOLVED] service: Failed to execute command: Exec format error
  20. #8 2017-12-01 10:22:02
  21. Re: [SOLVED] service: Failed to execute command: Exec format error
  22. #9 2017-12-03 12:09:54
  23. Re: [SOLVED] service: Failed to execute command: Exec format error
  24. 🛠️ Исправление ошибки «Exec format» при запуске скриптов командой run-parts
  25. Решение ошибки «Exec format» при запуске скриптов командой run-parts
  26. Перевод старого арча на systemd

Почему не работает созданная служба systemd?

Здравствуйте.
Появиласть необходимость запускать программу при загрузке системы и перезапускать в случае её закрытия или краха. Debian 8.1 располагает для этого инстументом systemd.
Был создан юнит с именем dts.service

Который запускает следующий скрипт /home/dts/bin/dts-service.sh

При выполнении этот скрипт запускает программу khconsole которая должна все время работать если она закрылась или повисла то systemd должен перезапустить её.

Проблема в следующем:
Отдельно, скрипт отрабатывает корректно. При попытке запуска через systemd получаю следующий результат
Job for dts.service failed. See ‘systemctl status dts.service’ and ‘journalctl -xn’ for details.

Результат systemctl status dts.service
dts.service — DTS deamon
Loaded: loaded (/etc/systemd/system/dts.service; enabled)
Active: failed (Result: start-limit) since Пт 2015-09-04 18:27:38 OMST; 28s ago
Process: 1058 ExecStart=/home/dts/bin/dts-service.sh (code=exited, status=203/EXEC)

сен 04 18:27:37 dts systemd[1]: Failed to start DTS deamon.
сен 04 18:27:37 dts systemd[1]: Unit dts.service entered failed state.
сен 04 18:27:38 dts systemd[1]: dts.service start request repeated too quickly, refusing to start.
сен 04 18:27:38 dts systemd[1]: Failed to start DTS deamon.
сен 04 18:27:38 dts systemd[1]: Unit dts.service entered failed state.

Результат journalctl -xn
— Logs begin at Пт 2015-09-04 18:12:17 OMST, end at Пт 2015-09-04 18:27:38 OMST. —
сен 04 18:27:37 dts systemd[1]: dts.service: control process exited, code=exited status=203
сен 04 18:27:37 dts systemd[1]: Failed to start DTS deamon.
— Subject: Ошибка юнита dts.service
— Defined-By: systemd
— Support: lists.freedesktop.org/mailman/listinfo/systemd-devel

— Произошел сбой юнита dts.service.

— Результат: failed.
сен 04 18:27:37 dts systemd[1]: Unit dts.service entered failed state.
сен 04 18:27:37 dts systemd[1058]: Failed at step EXEC spawning /home/dts/bin/dts-service.sh: Exec format error
— Subject: Не удалось запустить процесс /home/dts/bin/dts-service.sh
— Defined-By: systemd
— Support: lists.freedesktop.org/mailman/listinfo/systemd-devel

— Сбой: не удалось запустить процесс /home/dts/bin/dts-service.sh.

— Код ошибки: 8.
сен 04 18:27:37 dts systemd[1]: dts.service: control process exited, code=exited status=203
сен 04 18:27:37 dts systemd[1]: Failed to start DTS deamon.
— Subject: Ошибка юнита dts.service
— Defined-By: systemd
— Support: lists.freedesktop.org/mailman/listinfo/systemd-devel

— Произошел сбой юнита dts.service.

— Результат: failed.
сен 04 18:27:37 dts systemd[1]: Unit dts.service entered failed state.
сен 04 18:27:38 dts systemd[1]: dts.service start request repeated too quickly, refusing to start.
сен 04 18:27:38 dts systemd[1]: Failed to start DTS deamon.
— Subject: Ошибка юнита dts.service
— Defined-By: systemd
— Support: lists.freedesktop.org/mailman/listinfo/systemd-devel

— Произошел сбой юнита dts.service.

— Результат: failed.
сен 04 18:27:38 dts systemd[1]: Unit dts.service entered failed state.

Не понятно почему служба не стартует, хотя скрипт корректный и не должен завершаться?

Источник

Arch Linux

You are not logged in.

#1 2012-09-22 22:12:42

[SOLVED]Starup sript not getting executed in systemd

I have a script(rpi_user.sh) which has to be executed every time when I start my computer. But the startup script is not executing. Following are the steps which I have done. I am using systemd. I upgraded my system successfully today.

The script which I wanted to execute was very small and easy. I just creates a new file with the echoed text. Below is my script(rpi_user.sh)
cd /home/pi/
echo Jeffrey > 1

When ever I restart my system, I am not able to see the file ‘1’

I made the startup script(rpi_user.sh) and kept in /usr/bin. Also I followed the instruction in https://wiki.archlinux.org/index.php/Sy … process.3F

Below shown in my service file (rpi_user.service)
[Unit]
Description=rpi_user

After creating rpi_user.sh, I executed the following command to make the file executable — chmod +x rpi_user.sh

Once completing these steps, I executed the following commands (I got these info from http://forum.teamspeak.com/showthread.p … up-script)
# systemctl —system daemon-reload
# systemctl start rpi_user.service
# systemctl enable rpi_user.service
# systemctl status rpi_user.service

But things didn’t go fine. When I ran «systemctl status rpi_user.service», I got the following error

rpi_user.service — rpi_user
Loaded: loaded (/etc/systemd/system/rpi_user.service; enabled)
Active: failed (Result: exit-code) since Sun, 23 Sep 2012 03:29:08 +0530; 1min 33s ago
Main PID: 247 (code=exited, status=203/EXEC)
CGroup: name=systemd:/system/rpi_user.service

Sep 23 03:29:08 alarmpi systemd[247]: Failed at step EXEC spawning /usr/bin/rpi_user.sh: Exec format error

Could anyone of you answer the following questions.
1) Is there any thing wrong which I have done ? Is this the way to create startup scripts ?
2) Could you help me in fixing the issue — how can I make my starup script run ?

Thanks and Best Regards,
Jeffrey Antony
www.jeffrey.co.in

Last edited by Jayfree (2012-09-23 10:31:43)

Источник

Arch Linux

You are not logged in.

#1 2017-11-30 20:02:24

[SOLVED] service: Failed to execute command: Exec format error

After reading several threads and trying several things I still cannot get a custom service to start at boot. I need help.

Here is the story.

I want to delay some services at boot in order to decrease the boot time. So I made this (my first!) script

I tried putting the script in /usr/bin and in /usr/local/bin. It runs (manually) fine from either.

After that I created a service

as well as changing the type to

After that I created a timer

And after a reboot I have no internet connection. I have to manually run the script in order to start the services.

Script is executable

Here is the output

How to proceed to make it work?
Thank you in advance!

Last edited by amaro (2017-12-03 12:10:28)

#2 2017-11-30 20:06:42

Re: [SOLVED] service: Failed to execute command: Exec format error

I want to delay some services at boot in order to decrease the boot time.

Just stop here. This is completely the wrong approach. Delaying them will not decrease boot time. It may artificially decrease the numbers reported by `systemd-analze` but that does not mean you are getting to a useable system any faster.

«UNIX is simple and coherent. » — Dennis Ritchie, «GNU’s Not UNIX» — Richard Stallman

#3 2017-11-30 20:22:08

Re: [SOLVED] service: Failed to execute command: Exec format error

You sank my enthusiasm . I wanted it to work.
Anyway, ‘systemd-analyze’ showed improvement of 6 sec. But I am not to argue with you. I believe you are right. After all my knowledge is limited.

‘squid’ takes about 6 sec to start.

Last edited by amaro (2017-11-30 20:33:10)

#4 2017-11-30 21:23:30

Re: [SOLVED] service: Failed to execute command: Exec format error

You should use the Require and WantedBy to change the order on startup. See systemd-unit for details.

As a general recommendation: Always use absolute paths in units, e.g. /usr/bin/systemctl instead of systemctl.

#5 2017-11-30 22:05:37

Re: [SOLVED] service: Failed to execute command: Exec format error

Anyway, ‘systemd-analyze’ showed improvement of 6 sec.
‘squid’ takes about 6 sec to start.

Well there you have it. With squid starting at boot, systemd-analyze doesn’t report booting as «complete» until squid has started — but you will get to your login or desktop just as fast either way. Delaying squid will only delay squid, it will not speed up anything else.

«UNIX is simple and coherent. » — Dennis Ritchie, «GNU’s Not UNIX» — Richard Stallman

#6 2017-11-30 22:35:50

Re: [SOLVED] service: Failed to execute command: Exec format error

@Trilby squid.service is of type forking with WantedBy=multi-user.target so if amaro was using a display manager then
would the display manager only start after multi-user.target is complete which would would require squid.service to finish start up?

#7 2017-11-30 23:26:28

Re: [SOLVED] service: Failed to execute command: Exec format error

Perhaps, but that then would be the problem to be fixed, and starting important services intentionally after a delay is not a solution for that problem. Change the target they are wanted by, or change the dependency chain for the display manager, or — my favorite — ditch the DM as their primary purposes seem to be to slow down the boot process and break frequently.

«UNIX is simple and coherent. » — Dennis Ritchie, «GNU’s Not UNIX» — Richard Stallman

#8 2017-12-01 10:22:02

Re: [SOLVED] service: Failed to execute command: Exec format error

Delaying squid will only delay squid, it will not speed up anything else.

Absolutely right. But i did not know it.

Here is what I did in the meantime.

Changed ‘Type’ to ‘forking’ as loqs whispered to Trilby

@Trilby squid.service is of type forking with WantedBy=multi-user.target

After that I made two services — one for ‘dnsmasq’ and one for ‘squid’. Hooked them together in that order with a new ‘target’ file and started the ‘target’ file with the ‘timer’. Found the solution here https://jason.the-graham.com/2013/03/06 … md-timers/

It seems to work cause after rebooting I have access to internet. The only thing I don’t get is why the status of both services shows as ‘inactive’

#9 2017-12-03 12:09:54

Re: [SOLVED] service: Failed to execute command: Exec format error

I finally did it. Created ‘target’ file that ‘Requires’ ‘dhcpcd’, ‘dnmasq’, ‘squid’ and ‘iptables’. Created ‘crontab’ for squid-rotate. Started the ‘target’ with ‘timer’. Everything works fine. Overall gain — 3 sec.
Thank you Trilby and loqs! Your comments were very helpful!

Источник

🛠️ Исправление ошибки «Exec format» при запуске скриптов командой run-parts

Решение ошибки «Exec format» при запуске скриптов командой run-parts

Чтобы запустить все скрипты в папке «Documents», я запустил:

Я получил следующее сообщение об ошибке:

Bourne shell, или совместимый шеллl:

Bash:

Perl:

Python 2.x:

Python 3.x:

Это то, что мы называем шебанг.

Теперь вернемся к теме.

Отредактируйте ваши скрипты, используя ваш любимый редактор:

Добавьте шебанг в начале скрипта:

Теперь вы можете без проблем запускать скрипты с помощью команды run-parts, используя команду run-parts.

Вы также можете использовать утилиту ShellCheck для поиска проблем в своих скриптах оболочки.

  • Аудит ИБ (49)
  • Вакансии (12)
  • Закрытие уязвимостей (105)
  • Книги (27)
  • Мануал (2 234)
  • Медиа (66)
  • Мероприятия (39)
  • Мошенники (23)
  • Обзоры (800)
  • Обход запретов (34)
  • Опросы (3)
  • Скрипты (109)
  • Статьи (336)
  • Философия (99)
  • Юмор (18)

Anything in here will be replaced on browsers that support the canvas element

Источник

Перевод старого арча на systemd

sleepycat
для справки у системд должен быть свой планировщик, как и ЛОГометр.

Спасибо,всем спасибо. Сейчас буду перезагружаться,с богом !

UPD. И так,прикольная новая загрузочка,но старая почему то больше нравилась,в этой всё мелко как то =)
И да,что то там у меня сфейлилось,ругнулось на rc. что то там,но всё нормально загрузилось,щас посмотрим логи
эм,а где systemd держит логи о загрузке ?

RAMZAY
эм,а где systemd держит логи о загрузке ?

вот такие вот ошибки нашел в логе:

Oct 28 16:19:29 archlinux systemd: Starting /etc/rc.local Compatibility…
Oct 28 16:19:29 archlinux systemd: Failed at step EXEC spawning /etc/rc.local: Exec format error

ct 28 16:19:30 archlinux systemd: Failed to start /etc/rc.local Compatibility.
Oct 28 16:19:30 archlinux systemd: Unit rc-local.service entered failed state
Oct 28 16:19:30 archlinux /usr/sbin/crond: (CRON) INFO (Syslog will be used instead of sendmail.): Нет такого файла или каталога
Oct 28 16:19:30 archlinux /usr/sbin/crond: (CRON) INFO (running with inotify support)

Oct 28 16:19:49 archlinux pulseaudio: bluetooth-util.c: org.bluez.Manager.ListAdapters() failed: org.freedesktop.systemd1.LoadFailed: Unit dbus-org.bluez.service failed to load: No such file or directory. See system logs and ‘systemctl status dbus-org.bluez.service’ for details.

$ systemctl status dbus-org.bluez.service
dbus-org.bluez.service
Loaded: error (Reason: No such file or directory)
Active: inactive (dead)

RAMZAY
Oct 28 16:19:29 archlinux systemd: Starting /etc/rc.local Compatibility…
Oct 28 16:19:29 archlinux systemd: Failed at step EXEC spawning /etc/rc.local: Exec format error

ct 28 16:19:30 archlinux systemd: Failed to start /etc/rc.local Compatibility.
Oct 28 16:19:30 archlinux systemd: Unit rc-local.service entered failed state

RAMZAY
Oct 28 16:19:29 archlinux systemd: Starting /etc/rc.local Compatibility…
Oct 28 16:19:29 archlinux systemd: Failed at step EXEC spawning /etc/rc.local: Exec format error

ct 28 16:19:30 archlinux systemd: Failed to start /etc/rc.local Compatibility.
Oct 28 16:19:30 archlinux systemd: Unit rc-local.service entered failed state

а как выглядит rc-local.service? Я в свое время его не нашел, делал ручками по вики. Щас смотрю вики, а там уже и нету этого блока

То та и оно,вики нам вот что говорит

Чистая установка systemd
В конце концов, возможно вовсе удалить initscripts и sysvinit и использовать только лишь systemd.
1) Следуйте инструкциям для смешанной установки systemd/initscripts.
2) Убедитесь, что более не имеется каких-либо демонов для запуска из массива DAEMONS в конфигурационном файле /etc/rc.conf и оба файла /etc/rc.local и /etc/rc.local.shutdown пусты.
3) Удалите пакет initscripts из вашей системы.

да не паникуйте вы, может просто файла то и нет rc.local. Да и нужен ли он вам?

sleepycat
да не паникуйте вы, может просто файла то и нет rc.local. Да и нужен ли он вам?

# 10 лет, 2 месяца назад (отредактировано 10 лет, 2 месяца назад)

ну у меня он выглядит как то так

попробывал саздать,и включить,пишет ошибку. Ну и чёрт с ним.

© 2006-2023, Русскоязычное сообщество Arch Linux.
Название и логотип Arch Linux ™ являются признанными торговыми марками.
Linux ® — зарегистрированная торговая марка Linus Torvalds и LMI.

Источник

This document (7017128) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 12
SUSE Linux Enterprise Server 12 Service Pack 1 (SLES 12 SP1)

Situation

After enabling the after.local.service in SLE12, the service does not start at boot or after boot.

ls-boot:~ # systemctl status after.local
after.local.service
   Loaded: loaded (/etc/init.d/after.local)
   Active: failed (Result: exit-code) since Wed 2016-01-06 01:06:07 MST; 7h ago
  Process: 638 ExecStart=/etc/init.d/after.local start (code=exited, status=203/EXEC)

Jan 06 01:06:07 ls-boot systemd[1]: Failed to start after.local.service.

A restart of the service results in the following error:

ls-boot:~ # systemctl restart after.local
Job for after.local.service failed. See "systemctl status after.local.service" and "journalctl -xn" for details.

If you run journalctl and search for after.local, you see the following error:

ls-boot systemd[675]: Failed at step EXEC spawning /etc/init.d/after.local: Exec format error

The content of /etc/init.d/after.local is:

ls-boot:~ # cat /etc/init.d/after.local 
touch /var/log/test.log

Resolution

Add a hashpling to the beginning of /etc/init.d/after.local.

Change /etc/init.d/after.local from this:

ls-boot:~ # cat /etc/init.d/after.local 
touch /var/log/test.log

to this:

ls-boot:~ # cat /etc/init.d/after.local 
#!/bin/bash
touch /var/log/test.log

Reboot the server or restart the systemd processes as follows:

ls-boot:~ # systemctl daemon-reload
ls-boot:~ # systemctl restart after.local
ls-boot:~ # systemctl status after.local
after.local.service
   Loaded: loaded (/etc/init.d/after.local)
   Active: active (exited) since Wed 2016-01-06 09:32:19 MST; 11s ago
  Process: 2594 ExecStart=/etc/init.d/after.local start (code=exited, status=0/SUCCESS)

ls-boot:~ # ls -l /var/log/test.log
-rw-r--r-- 1 root root 0 Jan  6 09:32 /var/log/test.log

Cause

The /etc/init.d/after.local file was missing the hashpling at the beginning of the file. A hashpling is required for any systemd service script.

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented «AS IS» WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7017128
  • Creation Date:
    06-Jan-2016
  • Modified Date:03-Mar-2020
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

I have a java file which I’m trying to install as a service. But I’m getting errors. Below is the contents of my file and errors. I’m running Debian 8.

[Unit]
Description=App1Manager
After=syslog.target

[Service]
ExecStart=/usr/bin/jsvc -user root -cp /usr/share/java/commons-daemon.jar:/usr/local/myapp/bin/Manager.jar -pidfile /var/run/app1manager.pid

Type=forking

[Install]
WantedBy=multi-user.target

With either the below I get the following error:

SYSTEMD_LOG_LEVEL=debug /lib/systemd/system/myapp1 
SYSTEMD_LOG_LEVEL=debug /etc/init.d/myapp1 

/etc/init.d/myapp1: line 1: [Unit]: command not found
/etc/init.d/myapp1: line 6: [Service]: command not found
/etc/init.d/myapp1: line 7: -user: command not found
/etc/init.d/myapp1: line 10: [Install]: command not found


Aug 12 12:04:39 debian systemd[3903]: Failed at step EXEC spawning /etc/init.d/myapp1: Exec format error
-- Subject: Process /etc/init.d/myapp1 could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /etc/init.d/myapp1 could not be executed and failed.
--
-- The error number returned while executing this process is 8.
Aug 12 12:04:39 debian systemd[1]: myapp1.service: control process exited, code=exited status=203
Aug 12 12:04:39 debian systemd[1]: Failed to start (null).
-- Subject: Unit myapp1.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit myapp1.service has failed.
--
-- The result is failed.
Aug 12 12:04:39 debian systemd[1]: Unit myapp1.service entered failed state.

asked Aug 12, 2016 at 13:49

jaseUK's user avatar

1

Install to systemd/system with a .service file extension; the executable bit does not need to be set. Do not install systemd-format service files to /etc/init.d/; this is for legacy SysVinit style service scripts.

To start services, use systemctl start myapp1. When you’re not sure whether the service is implemented as systemd or SysV, use service myapp1 start.

To enable on boot [given an appropriate Install section] use systemctl enable myapp1.

answered Aug 12, 2016 at 14:18

sourcejedi's user avatar

sourcejedisourcejedi

46.4k16 gold badges132 silver badges273 bronze badges

0

User-774826108 posted

I am new to .net core and Ubuntu.

I am following this guide:
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?tabs=aspnetcore2x

I am working with a clean ASP.NET core 2.0 MVC project.

My service configuration file:

[Unit]
Description=Sample

[Service]
WorkingDirectory=/var/aspnetcore/sample
ExecStart=/var/aspnetcore/sample/sample.dll
Restart=always
# Restart service after 10 seconds if dotnet service crashes
RestartSec=10
SyslogIdentifier=sample
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

When I check status of the service I got:

root@xxx:~# systemctl status kestrel-sample.service
● kestrel-sample.service - Sample
   Loaded: loaded (/etc/systemd/system/kestrel-sample.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Fri 2018-03-30 15:01:46 +07; 9s ago
  Process: 13773 ExecStart=/var/aspnetcore/sample/sample.dll (code=exited, status=203/EXEC)
 Main PID: 13773 (code=exited, status=203/EXEC)

More details:

journalctl -xn
-- Logs begin at Fri 2018-03-30 11:43:27 +07, end at Fri 2018-03-30 15:01:18 +07. --
Mar 30 15:01:16 sample.com systemd[1]: kestrel-sample.service: Service hold-off time over, scheduling restart.
Mar 30 15:01:16 sample.com systemd[1]: Stopped Sample.
-- Subject: Unit kestrel-sample.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit kestrel-sample.service has finished shutting down.
Mar 30 15:01:16 sample.com systemd[1]: Started Sample.
-- Subject: Unit kestrel-sample.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit kestrel-sample.service has finished starting up.
--
-- The start-up result is done.
Mar 30 15:01:16 sample.com systemd[13743]: kestrel-sample.service: Failed at step EXEC spawning /var/aspnetcore/sample/sample.dll: Exec format error
-- Subject: Process /var/aspnetcore/sample/sample.dll could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /var/aspnetcore/sample/sample.dll could not be executed and failed.
--
-- The error number returned by this process is 8.
Mar 30 15:01:16 sample.com systemd[1]: kestrel-sample.service: Main process exited, code=exited, status=203/EXEC
Mar 30 15:01:16 sample.com systemd[1]: kestrel-sample.service: Unit entered failed state.
Mar 30 15:01:16 sample.com systemd[1]: kestrel-sample.service: Failed with result 'exit-code'.

I noticed error «Exec format error» and google it. Still can’t get it work. Please help!

Thanks,

I had followed the link for adding mongod as linux service.
after server restart, the mongod server is not restarted.

/etc/rc.d/init.d/mongod file content:

                #!/bin/bash
            #
            # mongodb     Startup script for the mongodb server
            #
            # chkconfig: - 64 36
            # description: MongoDB Database Server
            #
            # processname: mongodb
            #

            # Source function library
            . /etc/rc.d/init.d/functions

            if [ -f /etc/sysconfig/mongodb ]; then
                    . /etc/sysconfig/mongodb
            fi

            prog="mongod"
            mongod="/usr/bin/mongod"
            mongodb_user="myUserAdmin"
            RETVAL=0

            start() {
                    echo -n $"Starting $prog: "
                    #daemon $mongod "--fork --logpath /var/log/mongodb.log --logappend 2>&1 >>/var/log/mongodb.log"
                    daemon --user=$mongodb_user $mongod "--config /etc/mongodb.conf"
                    RETVAL=$?
                    echo
                    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
                    return $RETVAL
            }

            stop() {
                    echo -n $"Stopping $prog: "
                    killproc $prog
                    RETVAL=$?
                    echo
                    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
                    return $RETVAL
            }
            reload() {
                    echo -n $"Reloading $prog: "
                    killproc $prog -HUP
                    RETVAL=$?
                    echo
                    return $RETVAL
            }

            case "$1" in
                    start)
                            start
                            ;;
                    stop)
                            stop
                            ;;
                    restart)
                            stop
                            start
                            ;;
                    condrestart)
                            if [ -f /var/lock/subsys/$prog ]; then
                                    stop
                                    start
                            fi
                            ;;
                    reload)
                            reload
                            ;;
                    status)
                            status $mongod
                            RETVAL=$?
                            ;;
                    *)
                            echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
                            RETVAL=1
            esac

            exit $RETVAL

by referring the /var/log/messages

the error showing is

> Mar  4 09:04:44 redhat7 systemd: Starting SYSV: MongoDB Database Server...
Mar  4 09:04:44 redhat7 systemd: Failed at step EXEC spawning /etc/rc.d/init.d/mongod: Exec format error
Mar  4 09:04:44 redhat7 systemd: mongod.service: control process exited, code=exited status=203
Mar  4 09:04:44 redhat7 systemd: Failed to start SYSV: MongoDB Database Server.
Mar  4 09:04:44 redhat7 systemd: Unit mongod.service entered failed state.
Mar  4 09:04:44 redhat7 systemd: mongod.service failed.

please help me.

asked Mar 4, 2017 at 11:19

Telen Stanley's user avatar

Telen StanleyTelen Stanley

1551 gold badge2 silver badges7 bronze badges

2

Possibly not the answer you want, but you might consider a slightly different approach.

Your instructions date from 2013, and relate to the pre-systemd RedHat.
You have RedHat 7, which (AFAIK) has systemd, and I would recommend you use it, rather than use an init script.

Although I am surprised you don’t have a suitable script dropped into place when you installed mongo, I think it might make sense to consider using mongo’s own service unit for RPM based systems (taken from https://github.com/mongodb/mongo/blob/master/rpm/mongod.service):

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual

[Service]
User=mongod
Group=mongod
Environment="OPTIONS=--quiet -f /etc/mongod.conf"
ExecStart=/usr/bin/mongod $OPTIONS run
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings

[Install]
WantedBy=multi-user.target

You would want to put that into /etc/systemd/system/mongod.service, and possibly disable your init script.

answered Mar 4, 2017 at 13:43

iwaseatenbyagrue's user avatar

7

Понравилась статья? Поделить с друзьями:
  • Failed a general system error occurred missing vstor2 driver or not started
  • Failed to allocate memory call to arms как исправить
  • Failed a general system error occurred fault cause vim fault genericvmconfigfault
  • Failed to allocate from state pool black ops 2 как исправить
  • Fail with error bep20 transfer amount exceeds balance