淺談Linux配置定時,使用crontab -e與直接編輯/etc/crontab的區(qū)別
Linux配置定時任務,大家都知道使用crontab這個系統(tǒng)功能,但有時候我們需要區(qū)分用戶執(zhí)行,下面就直接說一下2種方法的區(qū)別:
方法1:
使用命令 crontab -e 然后直接編輯定時腳本。
這樣執(zhí)行以后,屬于用戶自定義的,會被寫到 /var/spool/cron 目錄下,生成一個和用戶名一致的文件,文件內(nèi)容就是我們編輯的定時腳本。
如:
[root@localhost cron.d]# cd /var/spool/cron [root@localhost cron]# ll 總用量 4 -rw-------. 1 root root 52 12月 9 10:58 root [root@localhost cron]# pwd /var/spool/cron [root@localhost cron]# cat root 30 03 * * * /root/automysqlbackup.sh
方法2:
使用命令 vi /etc/crontab 編輯定時腳本。
如:
[root@localhost ~]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 30 * * * * root /usr/sbin/ntpdate 210.72.145.44 #30 8 * * * root /usr/sbin/ntpdate 132.228.90.101 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly */1 * * * * root run-parts /opt/openoffice.org3/program/start.sh ############################################ 30 4 * * * root /usr/bin/rsync -vzrtopg --progress --delete root@192.168.231.35::resource /hyy/bak/resource 30 4 * * * root /usr/bin/rsync -vzrtopg --progress --delete root@192.168.231.35::log /hyy/bak/log ############################################ [root@localhost ~]#
(系統(tǒng)級的)做系統(tǒng)級配置我們會直接配置 /etc/crontab
(用戶級的)一般還是建議大家使用 crontab -e ,這樣系統(tǒng)也會幫著檢查我們配置的腳本語法。
以上這篇淺談Linux配置定時,使用crontab -e與直接編輯/etc/crontab的區(qū)別就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
- Linux crontab定時任務配置方法(詳解)
- 如何使用Linux的Crontab定時執(zhí)行PHP腳本的方法
- linux使用crontab實現(xiàn)PHP執(zhí)行計劃定時任務
- linux定時任務crontab 實現(xiàn)每秒執(zhí)行一次的方法
- linux下定時執(zhí)行任務的方法及crontab 用法說明(收集整理)
- Linux Crontab 啟動 、運行 和編輯 查看的命令
- 在linux上定期執(zhí)行命令、腳本(cron,crontab,anacron)
- Linux中crontab定時任務不執(zhí)行的原因
- linux crontab 實現(xiàn)每秒執(zhí)行的實例
- Linux定時任務Crontab詳解(推薦)
- Linux環(huán)境使用crontab命令設置定時周期性執(zhí)行任務【含php執(zhí)行代碼】
相關(guān)文章
django 利用pillow 進行簡單的設置驗證碼功能(python)
這篇文章主要介紹了django 利用pillow 進行簡單的設置驗證碼功能(python),非常不錯,具有一定的參考借鑒價值 ,需要的朋友可以參考下2019-08-08CentOS 5.11服務器安裝配置LAMP服務器(Apache+PHP5+MySQL)
這篇文章主要介紹了CentOS 5.11服務器安裝配置LAMP服務器(Apache+PHP5+MySQL),需要的朋友可以參考下2016-10-10Windows10使用Linux子系統(tǒng)實現(xiàn)輕松安裝多個linux
這篇文章主要為大家學習介紹了Windows10如何使用Linux子系統(tǒng)實現(xiàn)輕輕松松安裝多個linux,本文通過圖文為大家進行了詳細介紹,需要的可以收藏一下2023-08-08linux ubuntu中安裝、卸載和刪除python-igraph的方法教程
igraph是一個進行圖計算和社交網(wǎng)絡分析的軟件包,支持python語言。下面這篇文章主要給大家介紹了關(guān)于在linux ubuntu中安裝、卸載和刪除python-igraph的方法教程,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下。2017-11-11