zoukankan      html  css  js  c++  java
  • linux-crond_计划任务

    定时计划任务

      主要文件介绍:

    [root@nginx ~]# ll /etc/cron* -d
    drwxr-xr-x. 2 root root  21 7月  11 20:28 /etc/cron.d
    drwxr-xr-x. 2 root root  42 7月   5 05:16 /etc/cron.daily  #系统每天执行定时任务
    -rw-------. 1 root root   0 11月 20 2018 /etc/cron.deny   #黑名单
    drwxr-xr-x. 2 root root  22 7月  11 20:28 /etc/cron.hourly  #系统每小时
    drwxr-xr-x. 2 root root   6 6月  10 2014 /etc/cron.monthly  #系统每个月
    -rw-r--r--. 1 root root 451 6月  10 2014 /etc/crontab  #定时任务的主配置文件
    drwxr-xr-x. 2 root root   6 6月  10 2014 /etc/cron.weekly  #系统每周

      定时任务存放路径 

    [root@nginx cron]# pwd
    /var/spool/cron

      定时任务日志

    [root@nginx cron]# ll /var/log/cron
    -rw------- 1 root root 6744 8月  21 20:32 /var/log/cron

      定时计划任务配置文件参数介绍

    [root@nginx cron]# cat /etc/crontab 
    SHELL=/bin/bash  #定时任务的命令解释器
    PATH=/sbin:/bin:/usr/sbin:/usr/bin  #命令的环境变量
    MAILTO=root  #接收邮件的用户

      

      crontab定时任务命令主要参数:

        -e  #编辑定时任务

        -l  #查看定时任务

        -r  #删除定时任务文件

        -u  #指定用户,默认是当前用


    举例:(每分钟定时执行同步系统时间)

    安装软件:

    [root@nginx ~]# yum -y install ntpdate

    手动测试命令是否可以同步时间

    [root@nginx ~]# ntpdate ntp.aliyun.com
    21 Aug 20:43:58 ntpdate[1930]: adjust time server 203.107.6.88 offset -0.002605 sec

    编写定时任务

    [root@nginx cron]# crontab -e
    * * * * * ntpdate ntp.aliyun.com
    Aug 21 20:50:01 nginx CROND[2257]: (root) CMD (ntpdate ntp.aliyun.com)
    Aug 21 20:51:01 nginx CROND[2311]: (root) CMD (ntpdate ntp.aliyun.com)

    定时任务存放路径

    [root@nginx cron]# pwd  #文件以用户名命名
    /var/spool/cron
  • 相关阅读:
    [译]javascript中的条件语句
    [译]Javascript substring实例
    [译]Javasctipt中的substring
    [译]在Javascript中将string转化成numbers
    [译]Javascript基础
    [译]我们应该在HTML文档中何处放script标签
    [译]内联Javascript vs 外置Javascript
    [译]学习Javascript的工具
    MYSQL 重新设置自增值
    LINUX下的ssh登录之后的文件远程copy:scp命令(接前文ssh登录)
  • 原文地址:https://www.cnblogs.com/yangzhaon/p/11391337.html
Copyright © 2011-2022 走看看