This one time, at band camp, Voytek wrote:
>Peter Rundle said:
>> Command line parameters to a script appear as $1, $2, $3 etc with $0
>> being the script name and $# being the number or arguments. It's common
>> practise to do something like this at the beginning of the script,
>>    case $# in
>>    1)
>>      DOMAIN=$1
>>      ;;
>>    *)
>>      echo "Usage: $0 <domain.name>" 1>&2
>>      exit
>>      ;;
>>    esac
>>    if [ -s /home/$DOMAIN/logs/2004-access.log ]
>>    ...
>
>Peter, thanks
>above was exactly what I was aiming for.
>
>how can I time the execution lenght, and, write out a log at completion like
>
>$0 executed on date/time in xx sec
>
>into /var/logs/$0.log

starttime=`date +%s`

while true; do stuff; done

endtime=`date +%s`

exectime=$(($endtime - $starttime))

echo "$0 executed on date/time in $exectime sec" >> /var/logs/$0.log

-- 
[EMAIL PROTECTED]                           http://spacepants.org/jaq.gpg
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to