i'm facing a strange situation and i searched and haven't found anything. I have a bash script that take a date and add 72 hours to it. There is no problem when i run it from terminal but when it runs by cronjob it gaves me an error:
if [ $# -eq 3 ] ; then
# ----------
# PARAMETERS
# ----------
start_YYYYMMDDHH=${1}
ini_YYYYMMDDHH=${2}
flen=${3}
ini_HH=${ini_YYYYMMDDHH:8:2}
start_YYYY=${start_YYYYMMDDHH:0:4}
start_MM=${start_YYYYMMDDHH:4:2}
start_DD=${start_YYYYMMDDHH:6:2}
start_HH=${start_YYYYMMDDHH:8:2}
start_II=00
start_SS=00
end_YYYYMMDDHH=`date --utc +%Y%m%d%H%i%s -d "${start_YYYY}-${start_MM}-${start_DD} ${start_HH}:${start_II}:${start_SS} UTC +${flen} hours"`
end_YYYYMMDDHH=${end_YYYYMMDDHH:0:10}
end_YYYY=${end_YYYYMMDDHH:0:4}
end_MM=${end_YYYYMMDDHH:4:2}
end_DD=${end_YYYYMMDDHH:6:2}
end_HH=${end_YYYYMMDDHH:8:2}
end_II=00
end_SS=00
and when i run it by cron it gaves me this error:
date: extra operand ‘-d’ Try 'date --help' for more information.
do you have any idea why this is happening?
-d
operand? Perhaps another shell with an date buildin. Try to call the date command using it's absolute path.#!/bin/bash
) as you tell it's a bash script.