|
本帖最后由 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的第一个字母:
- if [ $1 = "-h" ]; then
- echo
- echo
- echo "___________New or Changed Files in the Last Hour _________________"
- echo
- 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}'
- echo "__________________________________________________________________"
- echo
- elif [ $1 = "-d" ]; then
- echo
- echo
- echo "___________New or Changed Files in the Last 24 Hours______________"
- echo
- 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}'
- echo "__________________________________________________________________"
- echo
- elif [ $1 = "-w" ]; then
- echo
- echo
- echo "___________New or Changed Files in the Last Week__________________"
- echo
- 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}'
- echo "__________________________________________________________________"
- echo
- elif [ $1 = "-m" ]; then
- echo
- echo
- echo "___________New or Changed Files in the Last Month_________________"
- echo
- 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}'
- echo "__________________________________________________________________"
- echo
- elif [ $1 = "-min" ]; then
- echo
- echo
- echo "___________New or Changed Files in Last Minite____________________"
- echo
- 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}'
- echo "__________________________________________________________________"
- echo
- elif [ $1 = "-y" ]; then
- echo
- echo
- echo "___________New or Changed Files in Last Year _____________________"
- echo
- 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}'
- echo "__________________________________________________________________"
- echo
- else
- echo "You input the WRONG Expression."
- echo "Usage: n [option]"
- echo "options: -min, -h, -d, -w, -m, -y"
- fi
复制代码
上述文件被命名为search_new_or_changed_files.sh
然后,去.bashrc加入这么两句话
- alias t="echo;uptime;echo;ps aux|grep -v '0.0 0.0'"
- alias n="sh search_new_or_changed_files.sh"
复制代码
好啦,命令n建立完毕(其实我还同时建立了一个t命令)
稍微解释一下:
- n -min 查看最近一分钟内新建的文件
- n -h 查看最近一小时内新建的文件
- n -d 查看最近一天内新建的文件
- n -w 查看最近一周内新建的文件
- n -m 查看最近一月内新建的文件
- n -y 查看最近一年内新建的文件(此参数慎用!!!!!!!!!!!!)
复制代码
如果你需要查看最近被新建或者被修改的文件是什么,这个命令可以直接用的。
其实到现在为止还跟高斯没啥关系呢
然后打开.bash_profile,加入以下行
- echo "_________Working Program__________________________________________"
- t
- echo "__________________________________________________________________"
- n -m
- n -m | grep ".log" | awk '{print $6}'> tmp_logfile_name
- echo "_________Gausssian Output Files in the Last Month_________________"
- while read line
- do
- echo
- echo $line
- grep " # " $line
- grep " #p " $line
- grep " #P " $line
- grep " #n " $line
- grep " #N " $line
- grep " #t " $line
- grep " #T " $line
- grep "Normal termination" $line
- grep "Error termination" $line
- echo "__________________________________________________________________"
- done < tmp_logfile_name
- rm -rf tmp_logfile_name
复制代码
好了,完毕。
只要登录服务器,服务器立刻甩给你这些信息
“我的负载有多重?我正在干什么活儿?我最近一个月新增的文件是谁?这些文件中,哪些是高斯的输出文件?这些输出文件的命令行是什么?它们是Normal termination还是Error Termination?”
举个例子吧,我登录服务器时候,我的服务器甩给我的信息如下:
- Last login: Sun Aug 9 17:25:59 2015 from 192.168.100.1
- ________NODE 16______________________________________________
- Hey, I am NODE 16! I have 12 CPU cores and 64GB memories.
- DO NOT use %nproc>12 and %mem>60GB.
- Before executing your jobs, DO confirm that I am empty!
- If you are kind to me, I can work for you in a very long time.
- Now I am already pleased to serve you at any time.
- ______________________________________________________________
- _________Working Program__________________________________________
- 17:50:51 up 1 day, 22 min, 2 users, load average: 0.00, 0.01, 0.05
- USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
- gdm 3912 0.3 0.2 1760540 143064 ? Sl Aug08 4:32 gnome-shell --mode=gdm
- __________________________________________________________________
- ___________New or Changed Files in the Last Month_________________
- Time: Jul 23 15:52 ------> /home/g/wcm/SubPc/Exercise/34-divine-twoboron-1.com
- Time: Jul 27 04:26 ------> /home/g/wcm/SubPc/Exercise/34-divine-twoboron-1.chk
- Time: Jul 29 19:44 ------> /home/g/wcm/SubPc/Exercise/25-e.fchk
- Time: Jul 29 19:44 ------> /home/g/wcm/SubPc/Exercise/25-e.chk
- Time: Jul 20 09:01 ------> /home/g/wcm/SubPc/Exercise/25-5-i-nn-ts-1.com
- Time: Jul 22 06:29 ------> /home/g/wcm/SubPc/Exercise/25-5-i-nn-ts-1.log
- Time: Jul 22 06:29 ------> /home/g/wcm/SubPc/Exercise/25-5-i-nn-ts-1.chk
- Time: Jul 27 04:26 ------> /home/g/wcm/SubPc/Exercise/34-divine-twoboron-1.log
- Time: Jul 29 19:36 ------> /home/g/wcm/Exercise/Cyx/9.com
- Time: Jul 29 19:36 ------> /home/g/wcm/Exercise/Cyx/nohup.out
- Time: Aug 3 15:41 ------> /home/g/wcm/Exercise/Cyx/9.log
- Time: Aug 3 15:41 ------> /home/g/wcm/Exercise/Cyx/9.chk
- Time: Jul 16 09:08 ------> /home/g/.ssh/known_hosts
- Time: Jul 13 11:05 ------> /home/g/q/sh-15-07-04-shanghong-CAM-B3LYP.gjf
- Time: Jul 13 11:58 ------> /home/g/q/sh-15-07-04-shanghong-CAM-B3LYP.log
- Time: Jul 13 11:58 ------> /home/g/q/sh-15-07-04-shanghong.chk
- Time: Jul 15 16:52 ------> /home/g/zly/S-f8bophf-td.chk
- Time: Jul 15 16:52 ------> /home/g/zly/S-f8bophf-td.com
- Time: Jul 15 16:52 ------> /home/g/zly/S-f8bophf-td.log
- Time: Jul 15 17:02 ------> /home/g/zly/S-tdulfine.com
- Time: Jul 15 17:27 ------> /home/g/zly/S-tdulfine.log
- Time: Jul 16 09:06 ------> /home/g/zly/S-tdulfine.chk
- Time: Jul 16 09:06 ------> /home/g/zly/S-tdulfine.fchk
- Time: Jul 16 13:25 ------> /home/g/zly/sub-td.com
- Time: Jul 16 22:25 ------> /home/g/zly/subC4-sp.log
- Time: Jul 16 22:32 ------> /home/g/zly/subC4-sp.chk
- Time: Jul 16 22:32 ------> /home/g/zly/subC4-sp.fchk
- Time: Jul 17 08:39 ------> /home/g/zly/sub-sp.com
- Time: Jul 17 08:43 ------> /home/g/zly/sub-sp.log
- Time: Jul 17 08:53 ------> /home/g/zly/sub-sp.chk
- Time: Jul 17 08:53 ------> /home/g/zly/sub-sp.fchk
- Time: Jul 27 17:42 ------> /home/g/zly/sub-td.chk
- Time: Jul 16 13:52 ------> /home/g/zly/sub-td.log
- Time: Jul 27 10:38 ------> /home/g/zly/subC4-td.com
- Time: Jul 27 11:09 ------> /home/g/zly/subC4-td.log
- Time: Jul 27 17:42 ------> /home/g/zly/subC4-td.chk
- Time: Jul 27 17:42 ------> /home/g/zly/sub-td.fchk
- Time: Jul 27 17:42 ------> /home/g/zly/subC4-td.fchk
- __________________________________________________________________
- _________Gausssian Output Files in the Last Month_________________
- /home/g/wcm/SubPc/Exercise/25-5-i-nn-ts-1.log
- #p opt=(qst2,maxcycle=200,loose,maxstep=5) freq=noraman 6-311+g(d) scr
- #P Geom=AllCheck Guess=TCheck SCRF=Check GenChk RM062X/6-311+G(d) Freq
- Normal termination of Gaussian 09 at Tue Jul 21 10:27:26 2015.
- Normal termination of Gaussian 09 at Wed Jul 22 06:29:55 2015.
- __________________________________________________________________
- /home/g/wcm/SubPc/Exercise/34-divine-twoboron-1.log
- #p opt=(qst2,maxcycle=200,loose,maxstep=5) freq=noraman 6-311+g(d) geo
- #P Geom=AllCheck Guess=TCheck SCRF=Check GenChk RM062X/6-311+G(d) Freq
- Normal termination of Gaussian 09 at Sat Jul 25 11:56:03 2015.
- Normal termination of Gaussian 09 at Mon Jul 27 04:26:18 2015.
- __________________________________________________________________
- /home/g/wcm/Exercise/Cyx/9.log
- #p nmr=giao mpw1pw91/gen pop=nboread
- __________________________________________________________________
- /home/g/q/sh-15-07-04-shanghong-CAM-B3LYP.log
- #p CAM-B3LYP lanl2dz td(nstates=30,conver=3)
- Normal termination of Gaussian 09 at Mon Jul 13 11:58:11 2015.
- __________________________________________________________________
- /home/g/zly/S-f8bophf-td.log
- #p td(nstates=50) m06/chkbasis geom=allcheck guess=read iop(9/46=48)
- #p td(nstates=50) m06/chkbasis geom=allcheck guess=read iop(9/46=48)\\
- Normal termination of Gaussian 09 at Mon Apr 20 18:35:55 2015.
- __________________________________________________________________
- /home/g/zly/S-tdulfine.log
- #p b3p86/6-31g(d) geom=allcheck guess=read td(nstates=18) scf(conver=6
- Normal termination of Gaussian 09 at Wed Jul 15 17:27:49 2015.
- __________________________________________________________________
- /home/g/zly/subC4-sp.log
- #p 6-311g(d) m06 nosymm
- Normal termination of Gaussian 09 at Thu Jul 16 22:25:47 2015.
- __________________________________________________________________
- /home/g/zly/sub-sp.log
- #p 6-311g(d) m06 nosymm
- Normal termination of Gaussian 09 at Fri Jul 17 08:43:21 2015.
- __________________________________________________________________
- /home/g/zly/sub-td.log
- #p td=(nstates=14) 6-311g(d) iop(9/40=5,9/46=12) m06 nosymm
- Normal termination of Gaussian 09 at Thu Jul 16 13:52:16 2015.
- __________________________________________________________________
- /home/g/zly/subC4-td.log
- #p 6-311g(d) m06 nosymm td(nstates=16) scf(conver=6) iop(9/40=5,9/46=1
- Normal termination of Gaussian 09 at Mon Jul 27 11:09:46 2015.
- __________________________________________________________________
复制代码
备注1:我举的例子中,最前面有一段“欢迎词”,那是motd里的,你们无视它吧,非常个人的东西。
备注2:我在.bash_profile中写了两次"n -m",这是查看最近一月内新建的文件。如果你想查看其他时间段,就把"-m"改成其他参数就好。
再举个例子吧,我自己把我的.bash_profile中写了两次"n -m"改成了"n -w"
效果如下
- _________Working Program__________________________________________
- 18:00:02 up 1 day, 31 min, 2 users, load average: 0.00, 0.01, 0.05
- USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
- gdm 3912 0.3 0.2 1760540 143064 ? Sl Aug08 4:34 gnome-shell --mode=gdm
- root 68811 3.0 0.0 116536 3116 pts/0 Ss+ 18:00 0:00 -bash
- __________________________________________________________________
- ___________New or Changed Files in the Last Week__________________
- Time: Aug 3 15:41 ------> /home/g/wcm/Exercise/Cyx/9.log
- Time: Aug 3 15:41 ------> /home/g/wcm/Exercise/Cyx/9.chk
- __________________________________________________________________
- _________Gausssian Output Files in the Last Week _________________
- /home/g/wcm/Exercise/Cyx/9.log
- #p nmr=giao mpw1pw91/gen pop=nboread
- __________________________________________________________________
复制代码
是不是简洁多了?
又换了台电脑试了试,效果是这样的。证明通用性
|
评分 Rate
-
查看全部评分 View all ratings
|