1

I have a process running in my server which user might not discard. I want to set a script which can calculate time difference and kill this automatically. Can anybody help me to calculate time difference between 2 dates in solaris?

Ricardo Altamirano
  • 14,650
  • 21
  • 72
  • 105
user1667374
  • 161
  • 1
  • 2
  • 8

2 Answers2

1

By a little searching, this link may help.

date1=$(/usr/xpg4/bin/awk 'BEGIN{srand();print srand()}')
# ... processing ...
date2=$(/usr/xpg4/bin/awk 'BEGIN{srand();print srand()}')
Ricardo Altamirano
  • 14,650
  • 21
  • 72
  • 105
Miao
  • 11
  • 1
1

This is what I have in a script that records how long it was running by computing the difference between start and end times:

START="$(perl -e 'print time')"
  [... body of script ...]
perl -e '$runtime = time - $ARGV[0];
         printf("Runtime: %d:%02d\n", $runtime/3600, ($runtime%3600)/60); ' \
        "${START}"
alanc
  • 4,102
  • 21
  • 24