I'm on FreeBSD11. I have a shell script code as cron job that check the zfs pool status and save it in a sqlite database. when I run it from terminal, it work properly but in crontab it does't work. The crontab:
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/etc/myjob/pool
#
#minute hour mday month wday who command
#
*/1 * * * * root /usr/local/etc/myjob/pool/pool.sh
my script is:
#!/bin/sh
pool=$(/sbin/zpool status | grep pool |awk '{print $2}')
for i in $pool
do
status=$(/sbin/zpool status ${i} |grep state|awk '{print $2}')
echo 'update mytbl set status = '\'''$status''\'';'|sqlite3 /usr/local/var/db/myproject/myDataBase.db
done
Can you help me figure out the mistake?
>/tmp/cronpool.log 2>&1
, for example.)crontab
, and if you did it by editing a file please provide its name and location.