I have the following code: (record.sh)
cd $(dirname $0)
dt=$(date '+%d/%m/%Y %H:%M:%S');
echo $dt;
read action < /home/nfs/sauger/web/pi/action.txt
echo $action;
if [[ $action == *"start"* ]]
then
echo "start recording"
./gone.sh
exit 1
elif [[ $action == *"stop"* ]]
then
echo "stop recording"
./gone.sh
exit 1
else
fi
When I run this script manually, the output is as follows:
19/01/2016 19:07:11
start
start recording
If the same script is run via (root) cronjob, the output is as follows:
19/01/2016 19:07:01
start
As you can see, the file "action.txt" was read without problems (the "launch" is logged both times), so this should not be a problem of permissions or wrong paths. But when you perform the cronjob role, the if statement is not called. There is no record "start recording".
So my question is: why does the if statement work when I call the script manually, but not when it is done via cron?
source
share