how to calculate time difference in solaris

怎甘沉沦 提交于 2019-12-25 00:24:42

问题


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?


回答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()}')



回答2:


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}"


来源:https://stackoverflow.com/questions/12471585/how-to-calculate-time-difference-in-solaris

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!