재부팅 후 블루투스를 비활성화하는 크론 작업이 작동하지 않는 이유는 무엇입니까?

재부팅 후 블루투스를 비활성화하는 크론 작업이 작동하지 않는 이유는 무엇입니까?

나는 원하지 않는 장치를 재부팅/시작할 때마다 Zorin이 블루투스를 활성화한다는 것을 알았습니다. 재부팅하기 전에 Bluetooth가 활성화되었는지 여부에 관계없이 항상 활성화되어 있습니다.

따라서 다음 크론 작업을 만들었습니다.

@reboot rfkill unblock bluetooth && /etc/init.d/bluetooth stop

이 명령에는 sudo 액세스가 필요 sudo crontab -e하므로 crontab -e.

이제 수동으로 실행하면 명령이 제대로 작동하지만 cron 작업은 재부팅 후에도 작동하지 않습니다.

뭐가 문제 야? 감사합니다!

OS: Zorin 16.2 (Ubuntu 20.04 LTS)
Codename: Focal
Kernel: 5.15.0-67-generic

편집하다:나는 팔로우한다@코드로드제안하고 명령을 쉘 스크립트에 넣으십시오.

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

rfkill unblock bluetooth
/etc/init.d/bluetooth stop

이것은 내 새로운 cronjob입니다.

@reboot ~/Applications/bash_scripts/disable_bluetooth.sh > ~/Applications/bash_scripts/disable_bluetooth.log 2>&1

그러나 disable_bluetooth.log기기를 다시 시작해도 해당 콘텐츠가 생성되지 않습니다. cron 작업이 전혀 실행되지 않는 것 같습니다.

편집 2:경로를 수정한 후 /home/pixelcode/...실제로 로그 파일이 예상대로 생성되어 다음과 같이 표시됩니다.

rfkill: command not found

편집 3:PATH다음 명령을 사용하여 루트 crontab에 추가 했습니다 sudo crontab -e.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@reboot /home/pixelcode/Applications/bash_scripts/disable_bluetooth.sh > /home/pixelcode/Applications/bash_scripts/disable_bluetooth.log 2>&1

이제 로그 파일에 다음이 표시됩니다.

Stopping bluetooth (via systemctl): bluetooth.service.

그러나 시스템 설정에 따르면 Bluetooth는 여전히 활성화되어 있습니다.

시스템 메뉴 옆에 있는 로그 파일은 모두 Bluetooth 서비스의 다양한 상태를 표시합니다.

관련 정보