美文网首页
Crontab定时

Crontab定时

作者: 吃橘子的冬天 | 来源:发表于2018-01-10 15:07 被阅读8次

定义

cron是系统主要的调度进程,可以在无需人工干预的情况下运行作业。crontab命令允许用户提交、编辑或删除相应的作业。每一个用户都可以有一个crontab文件来保存调度信息。系统管理员可以通过cron.deny 和 cron.allow 这两个文件来禁止或允许用户拥有自己的crontab文件。

  • crontab 服务
[root@etl_hadoop cron]# /etc/init.d/crond status
crond (pid  2199) is running...
  • 查看当前用户的定时任务
[root@etl_hadoop cron]#  crontab -l
# insert test log to /tmp/testlog/test.log
*/1 * * * * sh /tmp/testlog/log_generation.sh
  • 编辑当前用户的定时任务
[root@etl_hadoop cron]# crontab -e
# insert test log to /tmp/testlog/test.log
*/1 * * * * sh /tmp/testlog/log_generation.sh
~
~
  • 删除当前用户的定时任务
[root@etl_hadoop cron]# crontab -r
[root@etl_hadoop cron]# crontab -l
no crontab for root
  • crontab文件一般位于/etc/crontab下,这里面存放系统运行的的调度程序
[root@etl_hadoop cron]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
  • 每个用户自动生成一个自己的crontab文件,一般位于/var/spool/cron目录下
[root@etl_hadoop cron]# cat /var/spool/cron/root
16 1 * * 6 /usr/sbin/ntpdate ntp.bohailife.net>>/tmp/log;/sbin/hwclock -w
*/5 * * * * /usr/sbin/lsof -n|awk '{print $2}'|sort|uniq -c |sort -nr|awk 'NR==1'|awk '{print $1}' >/tmp/lsof.out

相关文章

  • crondtab 定时任务

    编辑定时任务 crontab -e 查看定时任务 crontab -l 删除定时任务 crontab -r 如:*...

  • linux crontab: 定时任务

    参考 crontab 定时任务 Linux之crontab定时任务

  • crond任务调度(定时任务调度)

    基本语法crontab [选项]选项-e : 编辑crontab定时任务-l : 查询crontab定时任务...

  • linux Crontab

    Linux Crontab:Linux中用于执行定时任务的工具crontab -e:编辑定时任务crontab -...

  • Crontab

    crontab命令: crontab定时任务: example:

  • Linux定时任务

    Linux定时任务 centOS: 使用crontab -e //编辑 crontab -l //查看定时任务 生...

  • mac 定时任务

    1、使用crontab设置定时任务 crontab -e 或者sudo crontab -e。 00 16 * *...

  • Linux定时任务

    >>>crontab -l #显示当前用户所有定时任务 >>>crontab -e #进入编辑定时任务模式 ...

  • Linux定时任务(2019-07-03)

    crontab -l 查询已有定时任务 crontab -e 编辑/新增定时任务 00 7 * * * /home...

  • 常用的linux命令

    ①定时任务管理: crontab –l 查看定时任务 crontab -e 编辑定时任务 ②查看实时日志: tai...

网友评论

      本文标题:Crontab定时

      本文链接:https://www.haomeiwen.com/subject/vdyonxtx.html