radc
2019-03-13 12:25:19 +08:00
其实搭配 sleep 是可以实现任意秒数间隔的 就是蛋疼了一点
比如想要 10s 间隔,那就取个分钟整数,做 sleep 10/20/30/40/50/60 6 个 cronjob (*/1 * * * *)
要 30s 间隔,就 sleep 30/60,两个 cronjob, (*/1 * * * *)
比如楼主想要 50s,那就取整到 300s,弄这么几个....... 每 300 秒装填 6 个任务,分别以 50 秒间隔来执行。
```
*/5 * * * * (sleep 50; echo `date` >> /tmp/50s.log)
*/5 * * * * (sleep 100; echo `date` >> /tmp/50s.log)
*/5 * * * * (sleep 150; echo `date` >> /tmp/50s.log)
*/5 * * * * (sleep 200; echo `date` >> /tmp/50s.log)
*/5 * * * * (sleep 250; echo `date` >> /tmp/50s.log)
*/5 * * * * (sleep 300; echo `date` >> /tmp/50s.log)
```
测试输出是这样,符合预期 挺 2b 的方法.... but it works! 😂
```
Wed Mar 13 12:15:51 CST 2019
Wed Mar 13 12:16:41 CST 2019
Wed Mar 13 12:17:31 CST 2019
Wed Mar 13 12:18:21 CST 2019
Wed Mar 13 12:19:11 CST 2019
Wed Mar 13 12:20:01 CST 2019
Wed Mar 13 12:20:52 CST 2019
Wed Mar 13 12:21:42 CST 2019
Wed Mar 13 12:22:32 CST 2019
```