beaglebone black で ssh なしでコードを実行する

beaglebone black で ssh なしでコードを実行する

電源を入れたときに何もBeaglebone blackせずにコードを実行したい。ssh

ファイル内のコードを実行するためのコマンドをいくつか入れてみました~/.bashrcが、 を使用してログインした場合にのみ機能しますssh。 ファイルで同じことを試しましたが/etc/rc.local、ssh 後でも機能しませんでした。

私も試してみました@reboot my_commandcrontab -e、SSH を使用してログインする必要があります。

助言がありますか??

編集:

root@beaglebone:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.6 (jessie)
Release:    8.6
Codename:   jessie

root@beaglebone:~# ps aux | grep cron | grep -v grep
root       295  0.0  0.3   4428  1988 ?        Ss   15:03   0:00 /usr/sbin/cron -f

出力crontab -e: 最後の数行

root@beaglebone:~# crontab -e
    # For more information see the manual pages of crontab(5) and cron(8)
    #
    # m h  dom mon dow   command


#@reboot /root/wiringBone-master/library/main           not working

#*/5 * * * * /root/wiringBone-master/library/main       works

main実行したいスクリプトは

root@beaglebone:~# systemctl enable cronie.service
Failed to execute operation: No such file or directory

許可と所有者main

root@beaglebone:~/wiringBone-master/library# ll main 
-rwxr-xr-x 1 root root 66744 May 27 16:15 main

答え1

Crontab が解決策です。次の方法で呼び出します:

crontab -e

デフォルトのエディターが開きます。以下を追加します。

@reboot your command

保存して終了します。コマンドにスーパーユーザーのパスワードが必要な場合は、まずsudo su -、およびcrontab -eroot として を実行する必要があります。

問題の原因(cron かスクリプトか)を突き止めるために、デバッグ用にもっと単純なケースを作成することができます。

  • まず、次のような行が@reboot date >> /root/acronジョブとして追加されます。crontab -e
  • うまくいけば(~ はファイル "/root/a" に日付/時刻を追加します)、その行は同じ所有権と権限(-rwxr-xr-x 1 root root)を持つ bash スクリプトに保存され、次のようになります。

    #!/usr/bin/sh
    date >> /root/a
    

関連情報