Linux下实现秒级的crontab定时任务
2016-11-11 17:01
363 查看
crontab的格式如下
如果需要间隔执行,可用通过 */间隔数字 的方式来实现,间隔执行,但是crontab的最小时间是每分钟但是可用通过bash脚本sleep来实现秒级定时。如下每秒执行一次/usr/local/php/bin/php /home/mao/Documents/crontab.php;
将脚本保存到
然后设置crontab定时任务,
加入
这样每分钟crontab就执行一次demo.sh,然后demo.sh是每秒执行一次对应的程序,然后休眠一下。这样就实现了,每秒的定时任务
* * * * * command 分 时 日 月 周 命令 第1列表示分钟1~59 每分钟用*或者 */1表示 第2列表示小时1~23(0表示0点) 第3列表示日期1~31 第4列表示月份1~12 第5列标识号星期0~6(0表示星期天) 第6列要运行的命令
如果需要间隔执行,可用通过 */间隔数字 的方式来实现,间隔执行,但是crontab的最小时间是每分钟但是可用通过bash脚本sleep来实现秒级定时。如下每秒执行一次/usr/local/php/bin/php /home/mao/Documents/crontab.php;
#!/bin/bash int=1; while(( $int<=60 )); do /usr/local/php/bin/php /home/mao/Documents/crontab.php; let "int++"; sleep 1; done
将脚本保存到
/home/mao/Documents/demo.sh
然后设置crontab定时任务,
crontab -e
加入
* * * * * /home/mao/Documents/demo.sh
这样每分钟crontab就执行一次demo.sh,然后demo.sh是每秒执行一次对应的程序,然后休眠一下。这样就实现了,每秒的定时任务
相关文章推荐
- Linux实现秒级定时任务(crontab)Shell小脚本
- Linux下实现秒级定时任务的两种方案(crontab 每秒运行)
- Linux下实现秒级定时任务的两种方案(crontab 每秒运行)
- Linux下实现秒级定时任务的两种方案(crontab 每秒运行)
- Linux下实现秒级定时任务的两种方案(Crontab 每秒运行)
- Linux下实现秒级定时任务的两种方案(crontab 每秒运行)
- Linux下实现秒级定时任务的两种方案(crontab 每秒运行)
- linux使用crontab实现PHP执行定时计划任务
- linux使用crontab实现PHP执行定时任务及codeiginter参数传递相关
- linux使用crontab实现PHP执行定时任务
- linux使用crontab实现PHP执行定时任务
- linux使用crontab实现php定时任务
- linux使用crontab实现PHP执行定时任务
- linux使用crontab实现PHP执行定时任务
- linux使用crontab实现PHP执行计划定时任务
- linux下使用crontab实现定时PHP计划任务失败的原因分析
- linux使用crontab实现PHP执行定时任务(转)
- crontab命令简介 linux定时设置 Cron实现自动任务
- linux中crontab的用法,shell实现定时任务
- linux使用crontab实现PHP执行定时任务