浅谈Linux配置定时,使用crontab -e与直接编辑/etc/crontab的区别
Linux配置定时任务,大家都知道使用crontab这个系统功能,但有时候我们需要区分用户执行,下面就直接说一下2种方法的区别:
方法1:
使用命令 crontab -e 然后直接编辑定时脚本。
这样执行以后,属于用户自定义的,会被写到 /var/spool/cron 目录下,生成一个和用户名一致的文件,文件内容就是我们编辑的定时脚本。
如:
[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 ~]#
(系统级的)做系统级配置我们会直接配置 /etc/crontab
(用户级的)一般还是建议大家使用 crontab -e ,这样系统也会帮着检查我们配置的脚本语法。
以上这篇浅谈Linux配置定时,使用crontab -e与直接编辑/etc/crontab的区别就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
- Linux crontab定时任务配置方法(详解)
- 如何使用Linux的Crontab定时执行PHP脚本的方法
- linux使用crontab实现PHP执行计划定时任务
- linux定时任务crontab 实现每秒执行一次的方法
- linux下定时执行任务的方法及crontab 用法说明(收集整理)
- Linux Crontab 启动 、运行 和编辑 查看的命令
- 在linux上定期执行命令、脚本(cron,crontab,anacron)
- Linux中crontab定时任务不执行的原因
- linux crontab 实现每秒执行的实例
- Linux定时任务Crontab详解(推荐)
- Linux环境使用crontab命令设置定时周期性执行任务【含php执行代码】
相关文章
Centos7配置fastdfs和nginx分布式文件存储系统实现过程解析
这篇文章主要介绍了centos7配置fastdfs及nginx并实现分布式文件存储系统,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下2020-06-06
Windows操作系统下Linux虚拟机的安装与配置教程图解
这篇文章主要介绍了Windows操作系统下Linux虚拟机的安装与配置,本文图文并茂给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下2019-10-10


最新评论