nohup はエラー 125 で終了します。

nohup はエラー 125 で終了します。

nohupバックグラウンドでPythonスクリプトを起動しようとするとエラー125で終了しますが、ワイルドカードを使用して同じファイルを指すとnohup正常に動作します。

    root@rpi_2:/home/pi/shortcuts# nohup -c bash 'python /home/pi/shortcuts/python/garage_topbutton_aio_pir_v2.py' > /dev/null 2>&1 &
[1] 26261
root@rpi_2:/home/pi/shortcuts#
[1]+  Exit 125                nohup -c bash 'python /home/pi/shortcuts/python/garage_topbutton_aio_pir_v2.py' > /dev/null 2>&1

root@rpi_2:/home/pi/shortcuts# ls /home/pi/shortcuts/python/garage_topbutton_aio_pir_v2.py
/home/pi/shortcuts/python/garage_topbutton_aio_pir_v2.py

root@rpi_2:/home/pi/shortcuts# nohup bash -c 'python /home/pi/shortcuts/python/*pir*v2*' > /dev/null 2>&1 &
[1] 26304

root@rpi_2:/home/pi/shortcuts# ps topbutton
USER       PID %CPU %MEM  START   TIME STAT COMMAND
root     26304  0.1  0.6  10:27   0:00 S<l  python /home/pi/shortcuts/python/garage_topbutton_aio_pir_v2.py
root@rpi_2:/home/pi/shortcuts#

以前はこんなことが起こったことがなかったので気になりました。

ベストアンサー1

nohup無効なオプションを取得すると、エラー125で終了します。

> /dev/null 2>&1リダイレクト()のため、エラーメッセージは表示されません。

$ nohup -c bash 'python /home/pi/shortcuts/python/garage_topbutton_aio_pir_v2.py'
nohup: invalid option -- 'c'
Try 'nohup --help' for more information.

-cしたがって、およびを交換したため、エラーが発生しますbash

また、ワイルドカードを使用しない場合はシェルを実行する必要がないため、この程度でスクリプトを実行するのに十分です。

nohup python /home/pi/shortcuts/python/garage_topbutton_aio_pir_v2.py > /dev/null >&1 &

おすすめ記事