Ubuntu サーバー、サービス/デーモンを起動しようとしています

Ubuntu サーバー、サービス/デーモンを起動しようとしています

私は指示に従いましたここしかし、「sudo service mydaemon start」と入力すると、「mydaemon: unrecognized service」というメッセージが表示されます。ファイルが適切な場所にあることを確認し、スクリプト ファイル (echoHW.sh) を実行可能にする追加手順を実行しましたが、まだ成功していません。どのような助けでもいただければ幸いです。

答え1

入力しsudo crontab -eてエディターとして選択しましたnano。以下のコメント付きの nano が起動しました。一番下にスクリプトを追加して再起動しました。これで、システムが起動するたびにタスクが実行されるようになりました。

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
@reboot /path/to/script.sh

答え2

/etc/init.d/(サービス名) でサービスを見つけて実行してみましたか?

init.d フォルダーの下にあるシェル プログラムを実際に実行せずにサービスを呼び出す方法には慣れていませんが、サービスを開始するシェル プログラムが init.d の下にある場合は、簡単にセットアップして、希望どおりに呼び出すことができるはずです - 「service mydaemon [コマンド]」

答え3

スクリプトが実行可能でない場合、このエラーが発生する可能性があります。

sudo chmod +x /etc/init.d/mydaemon

答え4

ルーターにポート転送を設定しましたか? 設定していない場合は、ポート転送と静的 IP アドレス + DNS (DNS プロバイダーから取得するか、独自の DNS サーバーを用意する必要があります) を設定します。ポート転送ここ。

関連情報