zoukankan      html  css  js  c++  java
  • 管理crontab

    管理定时任务
    
    Manage cron jobs.
    
    
    选项 ;
    
    ensure -- 定义cron entry 的状态,正确的参数是present,absent
    
    
    Manage cron entries.
    
    添加一个cron任务:
    
     cron_entry "reload-httpd",
       ensure       => "present",
       command      => "/etc/init.d/httpd restart",
       minute       => "1,5",
       hour         => "11,23",
       month        => "1,5",
       day_of_week  => "1,3",
       day_of_month => "1,3,5",
       user         => "root",
       on_change    => sub { say "cron added"; };
     
     # remove an entry
     cron_entry "reload-httpd",
       ensure       => "absent",
       command      => "/etc/init.d/httpd restart",
       minute       => "1,5",
       hour         => "11,23",
       month        => "1,5",
       day_of_week  => "1,3",
       day_of_month => "1,3,5",
       user         => "root",
       on_change    => sub { say "cron removed."; };
    
    =cut
    
    
    task "manage_cron", sub{
      cron_entry "date",
      ensure =>"present",
      command =>"date",
      minute => "1"
    };
       
       
       
    
    task "manage_cron", sub{
      cron_entry "date",
      ensure => "present",
      command => "date",
      minute => "1",
      hour  => '*',
      day_of_month   => '*',
      day_of_week => '*',
      user => 'root',
      on_change    => sub { say "cron added"; };
    };
       
       
    1 * * * * date
  • 相关阅读:
    linux下使用OpenCV的一些问题
    Google Colab调用cv2.imshow奔溃
    [LeetCode] Word Search
    信号
    信号
    [Leetcode] Subsets
    [LeetCode] Combinations
    [LeetCode] Minimum Window Substring
    [LeetCode] Set Matrix Zeroes
    sigaction 函数
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348707.html
Copyright © 2011-2022 走看看