crontab定时器

开启cron

sudo /etc/init.d/cron start

关闭cron

sudo /etc/init.d/cron stop

重启cron

sudo /etc/init.d/cron restart

crontab用法

crontab –e : 进入编辑 crontab 文件页面,如果文件不存在会自动创建。
crontab –l : 查看当前的定时任务
crontab -r : 删除 crontab 文件
crontab -ir : 删除 crontab 文件前提醒用户

crontab使用格式

分        小时     日        月      星期    命令

00-59  00-23  01-31  01-12   0-6    command

* 表示每,即当下时间段的所有时刻都会执行,例如月下面为*,则表示每月都会执行

crontab在爬虫中的使用

使用流程:

1、把爬虫启动命令写入sh文件

2、给sh脚本添加可执行权限

3、编辑crontab的配置文件

 

posted on 2018-12-31 11:20  77speed  阅读(172)  评论(0)    收藏  举报