Error while executing the below script

I am executing the below in telnet

#!/usr/bin/ksh
File1=simple.txt    # The file to check
LogFile=simple.log # The log file
DelayMax=30 # Timeout delay
Tolerance=2
# BEGIN ##############################
while true
do
    StampNow=$(date +%s)/60    # stamp in minutes
    StampFile=$(date -r "$File1" +%s)/60
    let Delay=$StampNow-$StampFile
    if [ $Delay -gt $DelayMax ]
    then
        echo "TIME STARTED = $(date +%Y-%m-%d_%H:%M:%S)" > $LogFile
	echo "TIME ENDED = $(date +%Y-%m-%d_%H:%M:%S)"  >> $LogFile
        # etc.
        exit 1
    elif [ $StampFile -eq $StampOld ]
    then
        sleep $Tolerance minutes # Retry a bit later
    else
        StampOld=$StampFile
        let NewDelay=$StampNow-$StampFile+15+$Tolerance # To synchronize with the updating
        sleep $NewDelay minutes
    fi
done

Below is the log

date: bad format character - s
date: illegal option -- r
Usage: date [-u] [+format]
       date [-u] [mmddhhmm[[cc]yy]]
       date [-a [-]sss.fff]
sam.ksh[11]: Delay=/60-/60: syntax error
sam.ksh[18]: /60: syntax error
sam.ksh[23]: NewDelay=/60-/60+15+2: syntax error
usage: sleep time

Please help i am a newbie in shell script

The format %s and option -r are only available with GNU version of date.

Jean-Pierre.

Could you please tell me the extact parameters that i need to chnge inorder to work

I am really newbie in shell scripting

You see those places where you're using %s and -r with date? As already said, you can't do that without GNU date. That's what you need to fix -- or rather, replace, since it's not broken as much as using programs you don't have.

The lack of good date manipulation in shell scripting's always bothered me, particularly since the GNU options are so obvious you'd think they'd be everywhere. But there's a few tricks. For instance the stat command can print out statistics on a file, including mtime in epoch seconds.

To get the current epoch time of a file in seconds, you can do:

EPOCH=`stat -c '%Y' "${FILE}"`

To get the current epoch time, you could use the above on a newly created file:

FILE=`mktemp`
EPOCH=`stat -c '%Y' ${FILE}`
rm "${FILE}"