crontab 的安装和使用

crontab

  • crontab 是linux 系统的一个定时任务
    -安装
    sudo apt install cron
    -安装完之后是服务是默认开启的(active)
  • 查看服务的状态service cron status
  • 重启服务 service cron restart
  • 停止服务 service cron stop
  • 开启服务 service cron start
  • 卸载
  • sudo apt remove cron
  • 1 安装完之后,默认的编辑器是nano, ctrl + o,保存,ctrl+ x 退出
  • 不习惯,修改编辑器:select -editor.
    我选的是3. /usr/bin/vim.basic。
  • 2 下来就可以编辑定时任务了
  • crontab -e ,有5个可选参数,分,时,天,月,星期
* * * * *  echo "good luck "  >>  /day.txt # 每隔一分钟执行一次 

crontab -l # 查看定时任务
crontab -r # 删除定时任务

猜你喜欢

转载自blog.csdn.net/weixin_44224529/article/details/91972378