
전원을 켤 때 Beaglebone black
수행하지 않고 일부 코드를 실행하고 싶습니다 .ssh
~/.bashrc
파일 에서 코드를 실행하기 위해 몇 가지 명령을 넣어 보았지만 ssh
. 파일 로 동일한 작업을 시도했지만 /etc/rc.local
ssh 이후에도 작동하지 않았습니다.
저도 시도했지만 @reboot my_command
SSH crontab -e
를 사용하여 로그인해야 합니다.
어떤 제안??
편집하다:
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 -e
.
문제의 원인(크론이든 스크립트이든)을 파악하기 위해 디버깅 목적으로 더 간단한 사례를 만들 수 있습니다.
- 먼저 다음과 같은 라인이
@reboot date >> /root/a
cron 작업으로 추가됩니다.crontab -e
작동하는 경우( ~는 "/root/a" 파일에 날짜/시간 추가) 해당 행은 동일한 소유권 및 권한(
-rwxr-xr-x 1 root root
)을 사용하여 다음과 같이 bash 스크립트에 저장됩니다.#!/usr/bin/sh date >> /root/a