shell - Crontab can't loop -


when type following in terminal ./dht 11 4 works , saves data mysql correctly.

id (1), temp (29), hum (37), date (2015...) 

when add crontab not work correctly.

id (1), temp (0 or empty), hum (0 or empty), date (2015...)  

sh script:

#!/bin/bash #dht11 script="/var/www/ernestynofailai/scripts/dht 11 4" #dht22 #script="/root/to/folder/dht 22 4" #am2302 #script="/root/to/folder/dht 2302 4" temp_and_hum="" while [[ $temp_and_hum == "" ]]     temp_and_hum=`$script | grep "temp"` done temp=`echo "$temp_and_hum" | cut -c8-9` hum=`echo "$temp_and_hum" | cut -c21-22` myqsl_user="root" myqsl_pw="pw" myqsl_database="dht" today=`date +"%y-%m-%d %t"` query="insert dht11 (temp, hum, date) values ('$temp', '$hum', '$today');" mysql --user=$myqsl_user --password=$myqsl_pw $myqsl_database << eof  $query eof 

and crontab:

*/1 * * * * /var/www/ernestynofailai/scripts/write_dht11_to_db.sh 

what can wrong?

long time ago, happened on systems cron didn't start shell scripts, binaries. had indicate explicitely interpreter use in crontab line

 */1 * * * * /bin/bash /var/www/ernestynofailai/scripts/write_dht11_to_db.sh 

i didn't check since, , dont know system using. on debian/jessie, told in crontab 5 manpage command executed /bin/sh, or shell specified shell variable in crontab file.

see https://superuser.com/questions/81262/how-to-execute-shell-script-via-crontab


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -