Shell指令碼 定時任務簡介

2021-10-21 21:17:30 字數 1073 閱讀 9081

利用【shell指令碼】一篇文章搞定shell指令碼的基礎知識點中的知識我們可以實現很多自動化運維指令碼的編寫,其中很重要的一種就是定時任務。

一次性定時任務可以使用命令at來建立,結束建立使用ctrl + d,使用atq命令可以來檢視當前使用者下還未執行的一次性計畫任務:

[root@centos8 ~]

# at 20:39

warning: commands will be executed using

/bin/sh

at> echo

"this is a one-time scheduled task" > /root/temp.txt

at> job 2 at fri mar 12 20:39:00 2021

[root@centos8 ~]

# atq

2 fri mar 12 20:39:00 2021 a root

[root@centos8 ~]

# date

fri mar 12 20:39:43 cst 2021

[root@centos8 ~]

# atq

[root@centos8 ~]

# cat /root/temp.txt

this is a one-time scheduled task

[root@centos8 ~]

# ls -lh /root/temp.txt

-rw-r--r-- 1 root root 34 mar 12 20:39 /root/temp.txt

[root@centos8 ~]

# crontab -l**

***/usr/bin/date >> /root/date.txt

[root@centos8 ~]

# tail -f /root/date.txt

fri mar 12 20:57:01 cst 2021

fri mar 12 20:58:01 cst 2021

Shell指令碼 定時任務

yum install vixie cron yum install crontabsservice crond start 啟動服務用以下的方法啟動 關閉這個cron服務 service crond start 啟動服務 service crond stop 關閉服務 service crond ...

Linux 執行定時任務 shell指令碼

linux上面執行定時任務,我們可以利用crontab e直接編輯定時任務 另外我們還可以寫好shell指令碼,定時去執行shell指令碼,這兩個方法都可以起到定時執行的作用 下面我詳細說一下入如何執行shell指令碼 bin bash echo yes home abc.txt儲存完畢後記得給予許...

Linux 執行定時任務 shell指令碼

linux上面執行定時任務,我們可以利用crontab e直接編輯定時任務 另外我們還可以寫好shell指令碼,定時去執行shell指令碼,這兩個方法都可以起到定時執行的作用 下面我詳細說一下入如何執行shell指令碼 1.宣告一下我安裝的lnmp環境,shell指令碼存放的位置在 usr loca...