shell脚本引用其他的脚本

 分类:Linux, Operating System 阅读 (754)  shell脚本引用其他的脚本已关闭评论
4月 202020
 

  有多个功能类似的脚本,用到同一个变量,但是这个变量有可能会根据需要改变,如果每个脚本文件定义一个这个变量,修改的时候每个脚本都要修改,很麻烦,所以想将这个变量定义在一个common.sh脚本里面,然后在功能脚本里面引用这个脚本,代码如下:

 

9月 022016
 

基本使用方法:

命令格式:
watch [options] command

选项:
-b, –beep    播放提示音当命令返回非0退出代码
-c, –color     interpret ANSI color sequences
-d, –differences[=<permanent>]      高亮显示每次更新的变化内容
-e, –errexit    当命令返回非0的退出代码时退出watch命令
-g, –chgexit     当命令输出内容变化时退出watch命令
-n, –interval <secs>      watch执行时间间隔,单位秒,可以小为数,最小可以为0.1秒
-p, –precise     attempt run command in precise intervals
-t, –no-title     关闭顶部Every 2.0s:提示
-x, –exec pass command to exec instead of “sh -c”

-h, –help display this help and exit
-v, –version output version information and exit

For more details see watch(1).

使用场景:

  1. 用于定时执行某个命令
  2. 用于定时查看某些文件或者系统状态的变化

使用举例: