クローンの操作に問題があります。たくさん試してみましたが、何も動作しません。私はcrontab -e
cronの編集に使用するRaspbianを使用しています。
1分ごとに2つのスクリプトを実行する必要があります。 Pythonスクリプト(.py)では機能しますが、SHでは機能しません。
*/1 * * * * /home/root/domoticz/scripts/DOMOTICZ/Home.py
*/1 * * * * /home/pi/Get_temp_bleville.sh
私は多くのフォーラムを読み、テスト目的で試したスクリプトの上部に追加または#!/bin/sh
追加しました。#!/bin/bash
chmod 777 Get_temp_bleville.sh
地域、グループ所有者(pi、ルート)、および次の構文を変更してみました。
*/1 * * * * /bin/sh /home/pi/Get_temp_bleville.sh
*/1 * * * * /bin/bash /home/pi/Get_temp_bleville.sh
*/1 * * * * bash /home/pi/Get_temp_bleville.sh
*/1 * * * * sh /home/pi/Get_temp_bleville.sh
*/1 * * * * root /home/pi/Get_temp_bleville.sh
やることはない:(
$ ls
-rwxrwxrwx 1 pi pi 228 déc. 19 21:19 Get_temp_bleville.sh
./script
orで直接bash
スクリプトを起動するとsh
機能します!
これはシェルスクリプトです
SHスクリプト:
#!/bin/sh
# Get Weather by API
wget -N http://api.wunderground.com/api/3b048a56ce883f41/conditions/q/pws:I76DOLLE2.json
# Get Temperature and parse file + create txt file with the temparature value
cat pws\:I76DOLLE2.json | jq '.current_observation.temp_c' | xargs echo > Temp_bleville.txt
どうですか?
ベストアンサー1
非対話型で実行されるシェルスクリプトをデバッグするとき、私はいつも次から始めます。
#!/bin/sh # or other shell
しかしすぐにフォローしてください。
# this redirects output to your log file & sends errors there also
exec > [full path of your own log file] 2>&1
# This makes the script output each command as it is executed
set +x
このため、次のようにパスを設定するか、コマンドの前にフルパス名を追加します。
export PATH=/bin:/usr/bin
または
/usr/bin/wget -N http://api.wunderground.com/api/3b048a56ce883f41/conditions/q/pws:I76DOLLE2.json