Cron jobs — to run every 5 seconds

前端 未结 6 674
轮回少年
轮回少年 2020-12-11 05:21

I want to create cron job that runs a script every 5 seconds. Seeing that cron jobs only allows increments of minutes 0-59 and so on.

I thought to create another scr

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-11 05:30

    I wouldn't use cron for this. I would use that bash script (use an absolute path, unless you want it to be portable and know that the directory structure will be preserved).

    Instead, I would just sleep 5, just like you did (only 5 seconds instead of 1).

    As far as starting it with your system, that depends on the system. On (some) Linux distros, there's a file called /etc/rc.local in which you can add scripts to run when the system starts. Well... I shouldn't be so general, the distros that I have used have this. If you're running Ubuntu, there is no longer an inittab, they use upstart, btw.

    So if you have an endless loop and an entry in /etc/rc.local, then you should be golden for it to run endlessly (or until it encounters a problem and exits).

提交回复
热议问题