Hi
I want to execute a cron job everyday at 14:50 hrs. I have a script like this:
TMP_FILE="/tmp/tmpcron.txt"
RES=0
/usr/bin/crontab -l >> $TMP_FILE
ADD_JOB="50 14 * * * /opt/mypath/scriptname.sh"
grep "scriptname.sh" $TMP_FILE >> /dev/null
JOB_NOT_EXIST=$?
if test $JOB_NOT_EXIST == 1
then
echo "$ADD_JOB" >> $TMP_FILE
/usr/bin/crontab $TMP_FILE >> /dev/null
RES=$?
fi
rm $TMP_FILE
exit $RES
However it is not getting executed at 14:50 Hrs. Can anyone tell me what I am missing?
why do you add same lines after every execute your script
/usr/bin/crontab -l >> $TMP_FILE
change to this
/usr/bin/crontab -l > $TMP_FILE
and firstly check yur cron job list before execute ttyoru script and then execute your script,
after check your cron list for is there a line for "scriptname.sh"
What Operating System and version do you have? What Shell are you using?
Try removing the redirect to /dev/null from the crontab command to see if there is any message.
Also try running crontab -l
to see if the new entry made it into the crontab.
If the entry is in the crontab, then look for errors in unix mail for the owner of the crontab and in the cron log.