久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

怎么在Linux中設(shè)置定時(shí)備份任務(wù)-創(chuàng)新互聯(lián)

這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)怎么在Linux中設(shè)置定時(shí)備份任務(wù),文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

成都創(chuàng)新互聯(lián)公司是一家專注于網(wǎng)站制作、網(wǎng)站建設(shè)與策劃設(shè)計(jì),西湖網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:西湖等地區(qū)。西湖做網(wǎng)站價(jià)格咨詢:18982081108

實(shí)現(xiàn)準(zhǔn)備

# 需要備份文件路徑:/opt/apollo/logs/access_log
[root@localhost opt]# cd apollo/
[root@localhost apollo]# tree
.
├── logs
│  └── access_log
└── test.sh
# 文件備份存放路徑:/tmp/logs
# 備份文件加上時(shí)間戳date + %Y%m%d%H%M%S

1.編寫shell腳本

[root@localhost tmp]# vi /opt/apollo/test.sh
# 編譯器
# !/bin/bash

# 日志備份到該目錄下,定義變量使用單引號(hào)
mypath='/tmp/logs'
# 回應(yīng)/tmp/logs
echo ${mypath}

# 要備份的日志
mylog='/opt/apollo/logs/access_log'
# 回應(yīng)/opt/apollo/logs/access_log
echo ${mylog}

# 時(shí)間戳,執(zhí)行命令使用``,esc下面的
time=`date +%Y%m%d%H%M%S`
# 回應(yīng)時(shí)間戳
echo ${time}

# 備份日志access_log到/tmp/logs路徑下
cp ${mylog} ${mypath}/${time}_access.log
# 回應(yīng)
echo ${mypath} ${mypath}/${time}_access.log

2.執(zhí)行test.sh

[root@localhost apollo]# ./test.sh
-bash: ./test.sh: Permission denied

3.執(zhí)行l(wèi)s -la

[root@localhost apollo]# ls -la
total 8
drwxr-xr-x  2 root root  21 Jan 20 08:00 .
drwxr-xr-x. 14 root root 4096 Jan 20 07:07 ..
-rw-r--r--  1 root root 489 Jan 20 08:00 test.sh

4.給文件test.sh賦與執(zhí)行權(quán)限

[root@localhost apollo]# chmod +x ./test.sh
[root@localhost apollo]# ls -la
total 8
drwxr-xr-x  2 root root  21 Jan 20 08:00 .
drwxr-xr-x. 14 root root 4096 Jan 20 07:07 ..
-rwxr-xr-x  1 root root 489 Jan 20 08:00 test.sh

5.再次執(zhí)行,腳本沒(méi)有報(bào)錯(cuò)

[root@localhost apollo]# ./test.sh
/tmp/logs
/opt/apollo/logs/access_log
20190120080932
/tmp/logs /tmp/logs/20190120080932_access.log

6.編輯定時(shí)任務(wù)

[root@localhost logs]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab

7.查看定時(shí)任務(wù)

# 每分鐘執(zhí)行一次test.sh
* * * * * sh /opt/apollo/test.sh

8.重啟crond

[root@localhost logs]# service crond reload
Redirecting to /bin/systemctl reload crond.service
You have new mail in /var/spool/mail/root

9.編寫文件access_log

# 需要備份文件路徑:
/opt/apollo/logs/access_log
# 編輯文件
[root@localhost logs]# vi /opt/apollo/logs/access_log
# 追加內(nèi)容如下:
mmmmmmmmmmmmmmmmmmmmm

10.過(guò)1分鐘,再去查備份存放目錄

[root@localhost logs]# cat 20190120083101_access.log
djddjsjsjsjjsjsjsj
mmmmmmmmmmmmmmmmmmmmm

11.到此為止,定時(shí)備份任務(wù)完成.

恭喜你,學(xué)會(huì)備份了!

12.刪除定時(shí)任務(wù)

[root@localhost logs]# crontab -r
You have new mail in /var/spool/mail/root

13.查看定時(shí)任務(wù)

[root@localhost logs]# crontab -l
no crontab for root
什么是Linux系統(tǒng)

Linux是一種免費(fèi)使用和自由傳播的類UNIX操作系統(tǒng),是一個(gè)基于POSIX的多用戶、多任務(wù)、支持多線程和多CPU的操作系統(tǒng),使用Linux能運(yùn)行主要的Unix工具軟件、應(yīng)用程序和網(wǎng)絡(luò)協(xié)議。

上述就是小編為大家分享的怎么在Linux中設(shè)置定時(shí)備份任務(wù)了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

本文名稱:怎么在Linux中設(shè)置定時(shí)備份任務(wù)-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)路徑:http://sd-ha.com/article36/jjgpg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化全網(wǎng)營(yíng)銷推廣、網(wǎng)站改版網(wǎng)站建設(shè)、云服務(wù)器品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)