五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動(dòng)態(tài)

Linux centos下設(shè)置定時(shí)備份任務(wù)的方法步驟

發(fā)布日期:2022-03-16 13:28 | 文章來源:站長(zhǎng)之家

實(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í)行,腳本沒有報(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.過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

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對(duì)1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部