Starting service on Linux throws a No such file or directory error

トラブルシューティング サービス

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

 

 

問題

After creating an init script for an application, running the service results in the following error:

env: /etc/init.d/your_init_script: No such file or directory

However, despite this error the init script can be seen in the correct location

 

診断

環境

  • This issue may occurs on *nix systems

Diagnostic Steps

  • Run the following command: cat -v /etc/init.d/your_init_script  
  • Examine the output, looking for ^M at the end of each line. These are carriage return characters.

原因

Carriage return characters have been inserted into your init script. Shell scripts may not be read correctly when unexpected carriage returns are encountered. Typically this might occur when the file was created via a Windows system, text editor, or terminal, as Windows uses carriage return + line feed characters for line endings, whereas *nix systems only use line feed characters

ソリューション

Remove the carriage return characters from the init script. This can be done with a sed one-liner:

sed -i -e 's/\r//g' /etc/init.d/your_init_script

This will remove the carriage return characters, after which you can start the service successfully

Last modified on Mar 30, 2016

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.