计算化学公社

标题: 可以让Gaussian用户懒惰到家的一些脚本 [打印本页]

作者
Author:
yjcmwgk    时间: 2015-8-9 17:55
标题: 可以让Gaussian用户懒惰到家的一些脚本
本帖最后由 yjcmwgk 于 2015-8-12 10:31 编辑

以前我发过查看当前服务器状态的脚本,这个是我写的(http://bbs.keinsci.com/forum.php?mod=viewthread&tid=1323
论坛里也有人给出了批量提交Gaussian任务的脚本,这个不是我(http://bbs.keinsci.com/forum.php?mod=viewthread&tid=520
论坛里甚至给出了“无耻”的抢资源提交Gaussian任务的脚本,这个更不是我啊(http://bbs.keinsci.com/forum.php?mod=viewthread&tid=1433
假期好无聊,我就寻思着还能干什么呢?
于是写了个“只要登录就能查看你的Gaussian任务状态”的脚本。
@jiewei
正文开始
首先,我们需要一个“查看最近被修改或被新建的文件的文件名”的命令。
这个命令被命名为n吧,取new的第一个字母:

  1. if [ $1 = "-h" ]; then
  2. echo
  3. echo
  4. echo "___________New or Changed Files in the Last Hour _________________"
  5. echo
  6. find /home -type f -mmin -1500 -ls | grep -v '/tmp' | grep -v 'bash' | grep -v 'lastnotifi'| grep -v 'viminfo' | awk '{print "Time:",$8,$9,$10,"------>",$11}'
  7. echo "__________________________________________________________________"
  8. echo
  9. elif [ $1 = "-d" ]; then
  10. echo
  11. echo
  12. echo "___________New or Changed Files in the Last 24 Hours______________"
  13. echo
  14. find /home -type f -mmin -24 -ls | grep -v '/tmp' | grep -v 'bash' | grep -v 'lastnotifi'| grep -v 'viminfo' | awk '{print "Time:",$8,$9,$10,"------>",$11}'
  15. echo "__________________________________________________________________"
  16. echo
  17. elif [ $1 = "-w" ]; then
  18. echo
  19. echo
  20. echo "___________New or Changed Files in the Last Week__________________"
  21. echo
  22. find /home -type f -mmin -10000 -ls | grep -v '/tmp' | grep -v 'bash' | grep -v 'lastnotifi'| grep -v 'viminfo' | awk '{print "Time:",$8,$9,$10,"------>",$11}'
  23. echo "__________________________________________________________________"
  24. echo
  25. elif [ $1 = "-m" ]; then
  26. echo
  27. echo
  28. echo "___________New or Changed Files in the Last Month_________________"
  29. echo
  30. find /home -type f -mmin -40000 -ls | grep -v '/tmp' | grep -v 'bash' | grep -v 'lastnotifi'| grep -v 'viminfo' | awk '{print "Time:",$8,$9,$10,"------>",$11}'
  31. echo "__________________________________________________________________"
  32. echo
  33. elif [ $1 = "-min" ]; then
  34. echo
  35. echo
  36. echo "___________New or Changed Files in Last Minite____________________"
  37. echo
  38. find /home -type f -mmin -1 -ls | grep -v '/tmp' | grep -v 'bash' | grep -v 'lastnotifi'| grep -v 'viminfo' | awk '{print "Time:",$8,$9,$10,"------>",$11}'
  39. echo "__________________________________________________________________"
  40. echo
  41. elif [ $1 = "-y" ]; then
  42. echo
  43. echo
  44. echo "___________New or Changed Files in Last Year  _____________________"
  45. echo
  46. find /home -type f -mmin -550000 -ls | grep -v '/tmp' | grep -v 'bash' | grep -v 'lastnotifi'| grep -v 'viminfo' | awk '{print "Time:",$8,$9,$10,"------>",$11}'
  47. echo "__________________________________________________________________"
  48. echo
  49. else
  50. echo "You input the WRONG Expression."
  51. echo "Usage: n [option]"
  52. echo "options:  -min, -h, -d, -w, -m, -y"
  53. fi
复制代码

上述文件被命名为search_new_or_changed_files.sh

然后,去.bashrc加入这么两句话
  1. alias t="echo;uptime;echo;ps aux|grep -v '0.0  0.0'"
  2. alias n="sh search_new_or_changed_files.sh"
复制代码


好啦,命令n建立完毕(其实我还同时建立了一个t命令)
稍微解释一下:
  1. n -min 查看最近一分钟内新建的文件
  2. n -h 查看最近一小时内新建的文件
  3. n -d 查看最近一天内新建的文件
  4. n -w 查看最近一周内新建的文件
  5. n -m 查看最近一月内新建的文件
  6. n -y 查看最近一年内新建的文件(此参数慎用!!!!!!!!!!!!)
复制代码

如果你需要查看最近被新建或者被修改的文件是什么,这个命令可以直接用的。
其实到现在为止还跟高斯没啥关系呢

然后打开.bash_profile,加入以下行
  1. echo "_________Working Program__________________________________________"
  2. t
  3. echo "__________________________________________________________________"

  4. n -m

  5. n -m | grep ".log" | awk '{print $6}'> tmp_logfile_name
  6. echo "_________Gausssian Output Files in the Last Month_________________"
  7. while read line
  8. do
  9.   echo
  10.   echo $line
  11.   grep " # " $line
  12.   grep " #p " $line
  13.   grep " #P " $line
  14.   grep " #n " $line
  15.   grep " #N " $line
  16.   grep " #t " $line
  17.   grep " #T " $line
  18.   grep "Normal termination" $line
  19.   grep "Error termination" $line
  20.   echo "__________________________________________________________________"
  21. done < tmp_logfile_name

  22. rm -rf tmp_logfile_name
复制代码



好了,完毕。
只要登录服务器,服务器立刻甩给你这些信息
“我的负载有多重?我正在干什么活儿?我最近一个月新增的文件是谁?这些文件中,哪些是高斯的输出文件?这些输出文件的命令行是什么?它们是Normal termination还是Error Termination?”

举个例子吧,我登录服务器时候,我的服务器甩给我的信息如下:

  1. Last login: Sun Aug  9 17:25:59 2015 from 192.168.100.1

  2.   ________NODE 16______________________________________________

  3.   Hey, I am NODE 16! I have 12 CPU cores and 64GB memories.
  4.   DO NOT use %nproc>12 and %mem>60GB.

  5.   Before executing your jobs, DO confirm that I am empty!

  6.   If you are kind to me, I can work for you in a very long time.
  7.   Now I am already pleased to serve you at any time.
  8.   ______________________________________________________________



  9. _________Working Program__________________________________________

  10. 17:50:51 up 1 day, 22 min,  2 users,  load average: 0.00, 0.01, 0.05

  11. USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
  12. gdm        3912  0.3  0.2 1760540 143064 ?      Sl   Aug08   4:32 gnome-shell --mode=gdm
  13. __________________________________________________________________


  14. ___________New or Changed Files in the Last Month_________________

  15. Time: Jul 23 15:52 ------> /home/g/wcm/SubPc/Exercise/34-divine-twoboron-1.com
  16. Time: Jul 27 04:26 ------> /home/g/wcm/SubPc/Exercise/34-divine-twoboron-1.chk
  17. Time: Jul 29 19:44 ------> /home/g/wcm/SubPc/Exercise/25-e.fchk
  18. Time: Jul 29 19:44 ------> /home/g/wcm/SubPc/Exercise/25-e.chk
  19. Time: Jul 20 09:01 ------> /home/g/wcm/SubPc/Exercise/25-5-i-nn-ts-1.com
  20. Time: Jul 22 06:29 ------> /home/g/wcm/SubPc/Exercise/25-5-i-nn-ts-1.log
  21. Time: Jul 22 06:29 ------> /home/g/wcm/SubPc/Exercise/25-5-i-nn-ts-1.chk
  22. Time: Jul 27 04:26 ------> /home/g/wcm/SubPc/Exercise/34-divine-twoboron-1.log
  23. Time: Jul 29 19:36 ------> /home/g/wcm/Exercise/Cyx/9.com
  24. Time: Jul 29 19:36 ------> /home/g/wcm/Exercise/Cyx/nohup.out
  25. Time: Aug 3 15:41 ------> /home/g/wcm/Exercise/Cyx/9.log
  26. Time: Aug 3 15:41 ------> /home/g/wcm/Exercise/Cyx/9.chk
  27. Time: Jul 16 09:08 ------> /home/g/.ssh/known_hosts
  28. Time: Jul 13 11:05 ------> /home/g/q/sh-15-07-04-shanghong-CAM-B3LYP.gjf
  29. Time: Jul 13 11:58 ------> /home/g/q/sh-15-07-04-shanghong-CAM-B3LYP.log
  30. Time: Jul 13 11:58 ------> /home/g/q/sh-15-07-04-shanghong.chk
  31. Time: Jul 15 16:52 ------> /home/g/zly/S-f8bophf-td.chk
  32. Time: Jul 15 16:52 ------> /home/g/zly/S-f8bophf-td.com
  33. Time: Jul 15 16:52 ------> /home/g/zly/S-f8bophf-td.log
  34. Time: Jul 15 17:02 ------> /home/g/zly/S-tdulfine.com
  35. Time: Jul 15 17:27 ------> /home/g/zly/S-tdulfine.log
  36. Time: Jul 16 09:06 ------> /home/g/zly/S-tdulfine.chk
  37. Time: Jul 16 09:06 ------> /home/g/zly/S-tdulfine.fchk
  38. Time: Jul 16 13:25 ------> /home/g/zly/sub-td.com
  39. Time: Jul 16 22:25 ------> /home/g/zly/subC4-sp.log
  40. Time: Jul 16 22:32 ------> /home/g/zly/subC4-sp.chk
  41. Time: Jul 16 22:32 ------> /home/g/zly/subC4-sp.fchk
  42. Time: Jul 17 08:39 ------> /home/g/zly/sub-sp.com
  43. Time: Jul 17 08:43 ------> /home/g/zly/sub-sp.log
  44. Time: Jul 17 08:53 ------> /home/g/zly/sub-sp.chk
  45. Time: Jul 17 08:53 ------> /home/g/zly/sub-sp.fchk
  46. Time: Jul 27 17:42 ------> /home/g/zly/sub-td.chk
  47. Time: Jul 16 13:52 ------> /home/g/zly/sub-td.log
  48. Time: Jul 27 10:38 ------> /home/g/zly/subC4-td.com
  49. Time: Jul 27 11:09 ------> /home/g/zly/subC4-td.log
  50. Time: Jul 27 17:42 ------> /home/g/zly/subC4-td.chk
  51. Time: Jul 27 17:42 ------> /home/g/zly/sub-td.fchk
  52. Time: Jul 27 17:42 ------> /home/g/zly/subC4-td.fchk
  53. __________________________________________________________________

  54. _________Gausssian Output Files in the Last Month_________________

  55. /home/g/wcm/SubPc/Exercise/25-5-i-nn-ts-1.log
  56. #p opt=(qst2,maxcycle=200,loose,maxstep=5) freq=noraman 6-311+g(d) scr
  57. #P Geom=AllCheck Guess=TCheck SCRF=Check GenChk RM062X/6-311+G(d) Freq
  58. Normal termination of Gaussian 09 at Tue Jul 21 10:27:26 2015.
  59. Normal termination of Gaussian 09 at Wed Jul 22 06:29:55 2015.
  60. __________________________________________________________________

  61. /home/g/wcm/SubPc/Exercise/34-divine-twoboron-1.log
  62. #p opt=(qst2,maxcycle=200,loose,maxstep=5) freq=noraman 6-311+g(d) geo
  63. #P Geom=AllCheck Guess=TCheck SCRF=Check GenChk RM062X/6-311+G(d) Freq
  64. Normal termination of Gaussian 09 at Sat Jul 25 11:56:03 2015.
  65. Normal termination of Gaussian 09 at Mon Jul 27 04:26:18 2015.
  66. __________________________________________________________________

  67. /home/g/wcm/Exercise/Cyx/9.log
  68. #p nmr=giao mpw1pw91/gen pop=nboread
  69. __________________________________________________________________

  70. /home/g/q/sh-15-07-04-shanghong-CAM-B3LYP.log
  71. #p CAM-B3LYP lanl2dz td(nstates=30,conver=3)
  72. Normal termination of Gaussian 09 at Mon Jul 13 11:58:11 2015.
  73. __________________________________________________________________

  74. /home/g/zly/S-f8bophf-td.log
  75. #p td(nstates=50) m06/chkbasis geom=allcheck guess=read iop(9/46=48)
  76. #p td(nstates=50) m06/chkbasis geom=allcheck guess=read iop(9/46=48)\\
  77. Normal termination of Gaussian 09 at Mon Apr 20 18:35:55 2015.
  78. __________________________________________________________________

  79. /home/g/zly/S-tdulfine.log
  80. #p b3p86/6-31g(d) geom=allcheck guess=read td(nstates=18) scf(conver=6
  81. Normal termination of Gaussian 09 at Wed Jul 15 17:27:49 2015.
  82. __________________________________________________________________

  83. /home/g/zly/subC4-sp.log
  84. #p 6-311g(d) m06 nosymm
  85. Normal termination of Gaussian 09 at Thu Jul 16 22:25:47 2015.
  86. __________________________________________________________________

  87. /home/g/zly/sub-sp.log
  88. #p 6-311g(d) m06 nosymm
  89. Normal termination of Gaussian 09 at Fri Jul 17 08:43:21 2015.
  90. __________________________________________________________________

  91. /home/g/zly/sub-td.log
  92. #p td=(nstates=14) 6-311g(d) iop(9/40=5,9/46=12) m06 nosymm
  93. Normal termination of Gaussian 09 at Thu Jul 16 13:52:16 2015.
  94. __________________________________________________________________

  95. /home/g/zly/subC4-td.log
  96. #p 6-311g(d) m06 nosymm td(nstates=16) scf(conver=6) iop(9/40=5,9/46=1
  97. Normal termination of Gaussian 09 at Mon Jul 27 11:09:46 2015.
  98. __________________________________________________________________

复制代码

备注1:我举的例子中,最前面有一段“欢迎词”,那是motd里的,你们无视它吧,非常个人的东西。
备注2:我在.bash_profile中写了两次"n -m",这是查看最近一月内新建的文件。如果你想查看其他时间段,就把"-m"改成其他参数就好。

再举个例子吧,我自己把我的.bash_profile中写了两次"n -m"改成了"n -w"
效果如下

  1. _________Working Program__________________________________________

  2. 18:00:02 up 1 day, 31 min,  2 users,  load average: 0.00, 0.01, 0.05

  3. USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
  4. gdm        3912  0.3  0.2 1760540 143064 ?      Sl   Aug08   4:34 gnome-shell --mode=gdm
  5. root      68811  3.0  0.0 116536  3116 pts/0    Ss+  18:00   0:00 -bash
  6. __________________________________________________________________


  7. ___________New or Changed Files in the Last Week__________________

  8. Time: Aug 3 15:41 ------> /home/g/wcm/Exercise/Cyx/9.log
  9. Time: Aug 3 15:41 ------> /home/g/wcm/Exercise/Cyx/9.chk
  10. __________________________________________________________________

  11. _________Gausssian Output Files in the Last Week _________________

  12. /home/g/wcm/Exercise/Cyx/9.log
  13. #p nmr=giao mpw1pw91/gen pop=nboread
  14. __________________________________________________________________
复制代码

是不是简洁多了?

又换了台电脑试了试,效果是这样的。证明通用性
(, 下载次数 Times of downloads: 41)

作者
Author:
lindlar    时间: 2015-8-10 08:04
学习啦,谢谢!
作者
Author:
aaa    时间: 2015-8-10 09:06
懒成这样……新手永远学不会linux shell了高手为新手提供了太多懒惰的机会
再次证明80%的贡献来自20%的人

作者
Author:
qczgzly    时间: 2015-8-10 10:25
实测效果不错
作者
Author:
zsu007    时间: 2015-8-10 11:43
谢谢分享!
作者
Author:
zidu113    时间: 2015-8-10 18:27
感谢,
作者
Author:
jiewei    时间: 2015-8-12 11:00
哈哈,谢谢小卒为大家分享。 话说 你艾特我 我不是这个班的版主啊
作者
Author:
yjcmwgk    时间: 2015-8-15 08:05
jiewei 发表于 2015-8-12 11:00
哈哈,谢谢小卒为大家分享。 话说 你艾特我 我不是这个班的版主啊

那你当超版就多好⊙▽⊙
作者
Author:
abdoman    时间: 2015-8-24 20:41
我觉得可以写一个function,变量加个时间就行。

作者
Author:
yjcmwgk    时间: 2015-8-28 17:26
本帖最后由 yjcmwgk 于 2015-8-28 17:31 编辑
abdoman 发表于 2015-8-24 20:41
我觉得可以写一个function,变量加个时间就行。

说的好有道理!可是我笨啊!当时没想过func,直接复制粘贴了。
真正的起因是,我以前给自己写过这个脚本
  1. echo "___________New or Changed Files in the Last 24 Hours______________"
  2. echo
  3. find /home -type f -mmin -1440 -ls | grep -v '/tmp' | grep -v 'bash' | grep -v 'lastnotifi'| grep -v 'viminfo' | awk '{print "Time:",$8,$9,$10,"------>",$11}'
  4. echo "__________________________________________________________________"
复制代码

当我发现我需要多个时间选择的时候,我……我太懒了,我直接把以前的脚本拿来复制粘贴了……我实在是懒成猪啊事实上我对bash的掌握其实挺差的……

作者
Author:
liyuanhe211    时间: 2015-10-29 00:44
为什么那段欢迎词里表明有16线程的时候最好不要用超过12个?
作者
Author:
yjcmwgk    时间: 2016-1-3 14:05
本帖最后由 yjcmwgk 于 2016-1-3 14:07 编辑
liyuanhe211 发表于 2015-10-29 00:44
为什么那段欢迎词里表明有16线程的时候最好不要用超过12个?

原因很简单,因为你看错了。哈哈哈哈(ಡωಡ)hiahiahia 。
这个节点的名字叫做第十六号节点,也就是node 16。这个节点中有两个E5-2643v2共十二个真实核心




欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3