Reputation: 170
a=$(iostat | awk 'FNR==4 {print $1}')
b=$(iostat | awk 'FNR==4 {print $2}')
c=$(iostat | awk 'FNR==4 {print $3}')
d=$(iostat | awk 'FNR==4 {print $4}')
e=$(iostat | awk 'FNR==4 {print $5}')
f=$(echo "scale=2;$a+$b+$c+$d+$e" | bc)
f=${f::-3}
echo $f >> /home/srikanth/tst
This is my code. I written it for cpu load. I wanted to schedule it in crontab for running it every minute. When i am executing it manually it working fine. but when i schedule it in crontab it is creating dead.letter with error
/home/srikanth/srk.sh: 7: /home/srikanth/srk.sh: Bad substitution
Can any one get me out of this
Thanks.....
Upvotes: 3
Views: 1649
Reputation: 21469
"Bad substitution" sounds like your shell can't handle your script. What shebang are you using? I assume cron runs your script with a different shell than the one you are using, e.g. dash instead of bash.
Try to add the following shebang to the start of your script and see if it fixes your problem:
#!/bin/bash
Upvotes: 7