數據倉庫005 - 複習Linux shell命令 - crontab調度 sh腳本 後臺執行 軟鏈接

1、crontab調度  

  對於linux 自帶crontab而言,      xxx.sh的通常編寫格式以#!/bin/bash 解釋器開頭,可在腳本中加入:mysql

date

  可是,shell腳本執行 須要 x權限,執行的方式以下:linux

  ./xxx.sh
  sh ./xxx.sh面試

  其中,後綴.sh 第一行#!/bin/bash 沒有,須要使用sh命令去執行sql

 

一、crontab簡單調度

[root@localhost ~]# crontab -e
no crontab for root - using an empty one
* * * * * /root/test.sh >> /root/test.log



#執行
[root@localhost ~]# crontab -l
* * * * * /root/test.sh >> /root/test.log
[root@localhost ~]# crontab -l
* * * * * /root/test.sh >> /root/test.log
[root@localhost ~]# 

其中,  shell

* * * * * 分別表明了分、小時、日、月、周、

    */6 */1=*
    * 表明 每

面試題: 每隔10s執行一次bash

[root@localhost ~]# cat test1.sh 
#!/bin/bash
for((i=1;i<=6;i++));
do

date
sleep 10s

done

exit
[root@localhost ~]# sh test1.sh 
2019年 11月 22日 星期五 02:53:18 CST
2019年 11月 22日 星期五 02:53:28 CST
2019年 11月 22日 星期五 02:53:38 CST

 

 

 

2.後臺執行

  ./test.sh &
  nohup ./test.sh & 手動啓動腳本 看日誌 開發維護 測試
  nohup ./test.sh > /root/test.log 2>&1 & 生產上測試

 

 

2、軟鏈接

[root@localhost ~]# ll
total 4
drwxr-xr-x 2 root root 6 Nov 20 21:33 mysql5.6 
drwxr-xr-x 2 root root 6 Nov 20 21:33 mysql5.7 
drwxr-xr-x 3 root root 44 Nov 17 23:13 ruozedata
-rw-r--r-- 1 root root 846 Nov 17 23:12 ruozedata.zip
[root@localhost ~]#

  ln -s 原path 目標pathspa

 

     CDH升級 原文件不見了 光標跳動:
  找原文件文件夾;
  刪除快捷鍵文件文件夾--》從新作新的軟鏈接 高版本日誌

相關文章
相關標籤/搜索