When I run a /bin/bash script, it works fine and it logs into some log files inside the script. But, when I run it from cron, it does not log to the file! it only logs to /var/mail/root , saying that
Date: Fri, 12 Aug 2016 08:39:01 +0300 (MSK)
/bin/sh: 1: root: not found
this is the script:
#!/bin/bash
LOG_FILE="test-crontab.log"
echo "started testing cron" >> ${LOG_FILE}
pgrep tunnel
if [[ ${?} != 0 ]]; then
echo "Tunnel process is not running..." | tee -a ${LOG_FILE}
echo "initializing tunnel..." | tee -a ${LOG_FILE}
/usr/local/bin/stunnel | tee -a ${LOG_FILE} 2>&1
fi
echo `date` >> ${LOG_FILE}
and this is the cron:
45 8 * * * /home/ubuntu/sam/scripts/sqlplus-scripts/accts-ct/test-crontab.sh > /dev/null
sh
but is usingbash
features, and (2) LOG_FILE should specify a complete path. (Neither of these issues, though, explains the error message.)chmod u+x /home/ubuntu/sam/scripts/sqlplus-scripts/accts-ct/test-crontab.sh
?